Index: openacs-4/packages/acs-templating/tcl/date-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/date-procs.tcl,v
diff -u -r1.62 -r1.63
--- openacs-4/packages/acs-templating/tcl/date-procs.tcl 8 Nov 2018 16:37:58 -0000 1.62
+++ openacs-4/packages/acs-templating/tcl/date-procs.tcl 9 Nov 2018 13:36:08 -0000 1.63
@@ -43,18 +43,18 @@
variable fragment_formats
variable token_exp
- array set month_data {
- 1 {January Jan 31}
- 2 {February Feb 28}
- 3 {March Mar 31}
- 4 {April Apr 30}
- 5 {May May 31}
- 6 {June Jun 30}
- 7 {July Jul 31}
- 8 {August Aug 31}
- 9 {September Sep 30}
- 10 {October Oct 31}
- 11 {November Nov 30}
+ array set month_data {
+ 1 {January Jan 31}
+ 2 {February Feb 28}
+ 3 {March Mar 31}
+ 4 {April Apr 30}
+ 5 {May May 31}
+ 6 {June Jun 30}
+ 7 {July Jul 31}
+ 8 {August Aug 31}
+ 9 {September Sep 30}
+ 10 {October Oct 31}
+ 11 {November Nov 30}
12 {December Dec 31}
}
@@ -78,7 +78,7 @@
# Reverse lookup
foreach key [array names fragment_widgets] {
set fragment_formats([lindex $fragment_widgets($key) 1]) $key
- }
+ }
# Expression to match any valid format token
set token_exp "([join [array names fragment_widgets] |])(t*)"
@@ -108,7 +108,7 @@
variable month_data
set month_desc $month_data($month)
set days [lindex $month_desc 2]
-
+
if { $month == 2
&& ( (($year % 4) == 0 && ($year % 100) != 0) ||
(($year % 400) == 0) )
@@ -120,11 +120,11 @@
}
ad_proc -public template::util::date::create {
- {year {}} {month {}} {day {}} {hours {}}
+ {year {}} {month {}} {day {}} {hours {}}
{minutes {}} {seconds {}} {format "DD MONTH YYYY"}
} {
Create a new Date object
- I chose to implement the date objects as lists instead of
+ I chose to implement the date objects as lists instead of
arrays, because arrays are not first-class in Tcl
} {
return [list $year $month $day $hours $minutes $seconds $format]
@@ -254,7 +254,7 @@
short_hours {
if {[lindex $date 3] eq ""} {
return {}
- } else {
+ } else {
set value [expr {[lindex $date 3] % 12}]
if { $value == 0 } {
return 12
@@ -266,7 +266,7 @@
ampm {
if {[lindex $date 3] eq ""} {
return {}
- } else {
+ } else {
if { [lindex $date 3] > 11 } {
return "pm"
} else {
@@ -278,7 +278,7 @@
for { set i 0 } { $i < 6 } { incr i } {
if { [lindex $date $i] ne {} } {
return 1
- }
+ }
}
return 0
}
@@ -302,14 +302,14 @@
}
set pad "00"
}
- # DRB: We need to differentiate between date and timestamp, for PG, at least,
- # and since Oracle supports to_timestamp() we'll just do it for both DBs.
+ # DRB: We need to differentiate between date and timestamp, for PG, at least,
+ # and since Oracle supports to_timestamp() we'll just do it for both DBs.
# DEDS: revert this first as to_timestamp is only for
# oracle9i. no clear announcement that OpenACS has dropped
# support for 8i
if { [llength $date] <= 3 || ([db_type] eq "oracle" && [string match "8.*" [db_version]]) } {
return "to_date('$value', '$format')"
- } else {
+ } else {
return "to_timestamp('$value', '$format')"
}
}
@@ -437,7 +437,7 @@
if {$value eq ""} {
return $date
}
-
+
# Erase leading zeroes from the value, but make sure that 00
# is not completely erased - but only for single-element properties
@@ -459,7 +459,7 @@
if { $value < 69 } {
return [lreplace $date 0 0 [expr {$value + 2000}]]
} else {
- return [lreplace $date 0 0 [expr {$value + 1900}]]
+ return [lreplace $date 0 0 [expr {$value + 1900}]]
}
}
short_hours {
@@ -468,7 +468,7 @@
ampm {
if {[lindex $date 3] eq ""} {
return $date
- } else {
+ } else {
set hours [lindex $date 3]
# robustness check: make sure we handle form of 08:00am --jfr
@@ -511,7 +511,7 @@
set matchdate {([0-9]{4})\-0?(1?[0-9])\-0?([1-3]?[0-9])}
set matchtime {0?([1-2]?[0-9]):0?([1-5]?[0-9]):0?([1-6]?[0-9])}
set matchfull "$matchdate $matchtime"
-
+
set time_p 1
if {![regexp -- $matchfull $value match ansi_year ansi_month ansi_days ansi_hours ansi_minutes ansi_seconds]} {
if {[regexp -- $matchdate $value match ansi_year ansi_month ansi_days]} {
@@ -551,18 +551,18 @@
}
ad_proc -public template::util::date::unpack { date } {
- Set the variables for each field of the date object in
+ Set the variables for each field of the date object in
the calling frame.
- sets: year month day hours minutes seconds format from a list formatted date string
+ sets: year month day hours minutes seconds format from a list formatted date string
@see template::util::date::from_ans
} {
uplevel [list foreach {year month day hours minutes seconds format} $date { break }]
}
ad_proc -public template::util::date::now_min_interval {} {
- Create a new Date object for the current date and time
+ Create a new Date object for the current date and time
with the default interval for minutes
@author Walter McGinnis (wtem@olywa.net)
@@ -572,7 +572,7 @@
foreach v [clock format [clock seconds] -format "%Y %m %d %H %M %S"] {
lappend now [util::trim_leading_zeros $v]
}
-
+
# manipulate the minute value so it rounds up to nearest minute interval
set minute [lindex $now 4]
# there is a definition for minute interval: 0 59 5
@@ -596,7 +596,7 @@
}
ad_proc -public template::util::date::now_min_interval_plus_hour {} {
- Create a new Date object for the current date and time
+ Create a new Date object for the current date and time
plus one hour
with the default interval for minutes
@@ -607,7 +607,7 @@
foreach v [clock format [clock seconds] -format "%Y %m %d %H %M %S"] {
lappend now [util::trim_leading_zeros $v]
}
-
+
# manipulate the minute value so it rounds up to nearest minute interval
set minute [lindex $now 4]
# there is a definition for minute interval: 0 59 5
@@ -632,10 +632,10 @@
}
ad_proc -public template::util::date::add_time { {-time_array_name:required} {-date_array_name:required} } {
- set the time and date and new format properties
+ set the time and date and new format properties
into one date object (list) which is returned
not sure this proc should live here...
-
+
@author Walter McGinnis (wtem@olywa.net)
@creation-date 2002-01-04
} {
@@ -649,7 +649,7 @@
# create an empty date object with the new format
set the_date [template::util::date::create \
"" "" "" "" "" "" ""]
-
+
set the_date [template::util::date::set_property format $the_date $new_format]
set have_values 0
@@ -697,7 +697,7 @@
return [list $the_date]
} else {
return {}
- }
+ }
}
ad_proc -public template::util::negative { value } {
@@ -729,7 +729,7 @@
set error_msg [list]
- foreach {field exp} { year "YYYY|YY" month "MM|MON|MONTH" day "DD"
+ foreach {field exp} { year "YYYY|YY" month "MM|MON|MONTH" day "DD"
hours "HH24|HH12" minutes "MI" seconds "SS" } {
# If the field is required, but missing, report an error
@@ -756,7 +756,7 @@
if { [string trimleft $month "0"] < 1 || [string trimleft $month "0"] > 12 } {
lappend error_msg [_ acs-templating.Month_must_be_between_1_and_12]
} else {
- if { $year > 0 } {
+ if { $year > 0 } {
if { $day ne {} } {
set maxdays [get_property days_in_month $date]
if { [string trimleft $day "0"] < 1 || [string trimleft $day "0"] > $maxdays } {
@@ -774,15 +774,15 @@
if { [template::util::negative $hours] || $hours > 23 } {
lappend error_msg [_ acs-templating.Hours_must_be_between_0_and_23]
- }
+ }
if { [template::util::negative $minutes] || $minutes > 59 } {
lappend error_msg [_ acs-templating.Minutes_must_be_between_0_and_59]
- }
+ }
if { [template::util::negative $seconds] || $seconds > 59 } {
lappend error_msg [_ acs-templating.Seconds_must_be_between_0_and_59]
- }
+ }
if { [llength $error_msg] > 0 } {
set error_msg "[join $error_msg {
}]"
return 0
@@ -824,9 +824,9 @@
# interval_def is in form { start stop interval }
ad_proc -public template::widget::numericrange {element_reference tag_attributes} {
- Widget proc usable with ad_form, need to define interval_def as
+ Widget proc usable with ad_form, need to define interval_def as
{interval_def {start end step}}
-} {
+} {
upvar $element_reference element
if { [info exists element(html)] } {
@@ -841,7 +841,7 @@
interval_def is in form { start stop interval }
} {
array set attributes $tag_attributes
-
+
set interval_size [lindex $interval_def 2]
set options [list [list "--" {}]]
@@ -871,7 +871,7 @@
} {
upvar $element_reference element
-
+
set value [template::util::date::get_property $fragment $value]
set value [util::trim_leading_zeros $value]
@@ -882,8 +882,8 @@
set interval $element(${fragment}_interval)
} else {
# Display text entry for some elements, or if the type is text
- if { $type == "t"
- || [regexp "year|short_year" $fragment]
+ if { $type == "t"
+ || [regexp "year|short_year" $fragment]
} {
set output "