• Publicity: Public Only All

date-procs.tcl

Date widgets for the ArsDigita Templating System

Location:
packages/acs-templating/tcl/date-procs.tcl
Author:
Stanislav Freidin <sfreidin@arsdigita.com>
CVS Identification:
$Id: date-procs.tcl,v 1.63.2.18 2022/01/30 14:38:58 gustafn Exp $

Procedures in this file

Detailed information

template::data::from_sql::date (public)

 template::data::from_sql::date value

Reads an ANSI date as a templating date object.

Parameters:
value

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 template::data::from_sql::time_of_day template::data::from_sql::time_of_day (public) template::data::from_sql::date template::data::from_sql::date template::data::from_sql::time_of_day->template::data::from_sql::date template::data::from_sql::timestamp template::data::from_sql::timestamp (public) template::data::from_sql::timestamp->template::data::from_sql::date

Testcases:
No testcase defined.

template::data::from_sql::time_of_day (public)

 template::data::from_sql::time_of_day value

Reads an ANSI time of day as a templating date object.

Parameters:
value

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::data::from_sql::timestamp (public)

 template::data::from_sql::timestamp value

Reads an ANSI timestamp as a templating date object.

Parameters:
value

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::data::to_sql::date (public)

 template::data::to_sql::date value

Converts a templating date object into a SQL date.

Parameters:
value

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 template::data::to_sql::time_of_day template::data::to_sql::time_of_day (public) template::data::to_sql::date template::data::to_sql::date template::data::to_sql::time_of_day->template::data::to_sql::date template::data::to_sql::timestamp template::data::to_sql::timestamp (public) template::data::to_sql::timestamp->template::data::to_sql::date

Testcases:
No testcase defined.

template::data::to_sql::time_of_day (public)

 template::data::to_sql::time_of_day value

Converts a templating date object into a SQL time.

Parameters:
value

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::data::to_sql::timestamp (public)

 template::data::to_sql::timestamp value

Converts a templating date object into a SQL timestamp.

Parameters:
value

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::data::transform::date (public)

 template::data::transform::date element_ref

Collect a Date object from the form.

Parameters:
element_ref

Partial Call Graph (max 5 caller/called nodes):
%3 template::data::transform::time_of_day template::data::transform::time_of_day (public) template::data::transform::date template::data::transform::date template::data::transform::time_of_day->template::data::transform::date template::data::transform::timestamp template::data::transform::timestamp (public) template::data::transform::timestamp->template::data::transform::date

Testcases:
No testcase defined.

template::data::transform::textdate (public)

 template::data::transform::textdate element_ref

Collect a textdate from the form, it automatically reformats it from the users locale to the ISO standard YYYY-MM-DD this is useful because it doesn't need reformatting in Tcl code.

Parameters:
element_ref

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::data::transform::time_of_day (public)

 template::data::transform::time_of_day element_ref

Collect a time_of_day object from the form.

Parameters:
element_ref

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::data::transform::timestamp (public)

 template::data::transform::timestamp element_ref

Collect a timestamp object from the form.

Parameters:
element_ref

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::data::validate::h5date (public)

 template::data::validate::h5date value_ref message_ref

Validate a date submitted via HTML 5 input type "date". The submitted value is also checked against any "min" and "max" constraint set on the input element itself.

Parameters:
value_ref - Reference variable to the submitted value.
message_ref - Reference variable for returning an error message.
Returns:
True (1) if valid, false (0) if not.

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::data::validate::h5time (public)

 template::data::validate::h5time value_ref message_ref

Validate that a date submitted via HTML 5 input type "time". The sbumitted value is also checked against any set "min" and "max" constraint set on the input element itself.

Parameters:
value_ref - Reference variable to the submitted value.
message_ref - Reference variable for returning an error message.
Returns:
True (1) if valid, false (0) if not.

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::date (public)

 template::util::date command [ args... ]

Dispatch procedure for the date object

Parameters:
command

Partial Call Graph (max 5 caller/called nodes):
%3 template::util::date::set_property template::util::date::set_property (public) template::util::date template::util::date template::util::date::set_property->template::util::date

Testcases:
No testcase defined.

template::util::date::acquire (public)

 template::util::date::acquire type [ value ]

Create a new date with some predefined value. Basically, create and set the date.

Parameters:
type
value (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 template::data::from_sql::date template::data::from_sql::date (public) template::util::date::acquire template::util::date::acquire template::data::from_sql::date->template::util::date::acquire

Testcases:
No testcase defined.

template::util::date::add_time (public)

 template::util::date::add_time -time_array_name time_array_name \
    -date_array_name date_array_name

Set the time and date and new format properties into one date object (list) which is returned. Not sure this proc should live here...

Switches:
-time_array_name (required)
-date_array_name (required)
Author:
Walter McGinnis <wtem@olywa.net>
Created:
2002-01-04

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::date::compare (public)

 template::util::date::compare date1 date2

Perform date comparison; same syntax as string compare.

Parameters:
date1
date2

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::date::create (public)

 template::util::date::create [ year ] [ month ] [ day ] [ hours ] \
    [ minutes ] [ seconds ] [ format ]

Create a new Date object. This is defined as a list of 7 elements, respectively representing year, month, day, hours, minutes, seconds and format.

Parameters:
year (optional)
month (optional)
day (optional)
hours (optional)
minutes (optional)
seconds (optional)
format (defaults to "DD MONTH YYYY")

Partial Call Graph (max 5 caller/called nodes):
%3 calendar::from_sql_datetime calendar::from_sql_datetime (public) template::util::date::create template::util::date::create calendar::from_sql_datetime->template::util::date::create template::data::transform::date template::data::transform::date (public) template::data::transform::date->template::util::date::create template::util::date::acquire template::util::date::acquire (public) template::util::date::acquire->template::util::date::create template::util::date::add_time template::util::date::add_time (public) template::util::date::add_time->template::util::date::create template::util::date::from_ansi template::util::date::from_ansi (public) template::util::date::from_ansi->template::util::date::create

Testcases:
No testcase defined.

template::util::date::daysInMonth (public)

 template::util::date::daysInMonth month [ year ]
Parameters:
month
year (defaults to "0") - an integer representing the number of the year in the Gregorian calendar.
Returns:
the number of days in a month, accounting for leap years.

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 template::util::date::get_property template::util::date::get_property (public) template::util::date::daysInMonth template::util::date::daysInMonth template::util::date::get_property->template::util::date::daysInMonth

Testcases:
No testcase defined.

template::util::date::defaultInterval (public)

 template::util::date::defaultInterval what

Get the default ranges for all the numeric fields of a Date object

Parameters:
what

Partial Call Graph (max 5 caller/called nodes):
%3 template::util::date::now_min_interval template::util::date::now_min_interval (public) template::util::date::defaultInterval template::util::date::defaultInterval template::util::date::now_min_interval->template::util::date::defaultInterval template::util::date::now_min_interval_plus_hour template::util::date::now_min_interval_plus_hour (public, deprecated) template::util::date::now_min_interval_plus_hour->template::util::date::defaultInterval template::widget::dateFragment template::widget::dateFragment (public) template::widget::dateFragment->template::util::date::defaultInterval

Testcases:
No testcase defined.

template::util::date::from_ansi (public)

 template::util::date::from_ansi ansi_date [ format ]

Create a new templating system date structure from a full ANSI date, i.e. in the format YYYY-MM-DD HH24:MI:SS.

Parameters:
ansi_date - Date in full ANSI format YYYY-MM-DD HH24:MI:SS (time portion is optional).
format (defaults to "YYYY MM DD") - Format for the date object. Optional, defaults to YYYY MM DD.
Returns:
Date object for use with e.g. form builder.
Author:
Lars Pind <lars@pinds.com>
Created:
November 18, 2002

Partial Call Graph (max 5 caller/called nodes):
%3 packages/calendar/www/cal-item-new.tcl packages/calendar/ www/cal-item-new.tcl template::util::date::from_ansi template::util::date::from_ansi packages/calendar/www/cal-item-new.tcl->template::util::date::from_ansi

Testcases:
No testcase defined.

template::util::date::get_property (public)

 template::util::date::get_property what date

Returns a property of a date list, usually created by ad_form.

Parameters:
what - the name of the property. One of:
  • year
  • month
  • day
  • hours
  • minutes
  • seconds
  • format
  • long_month_name
  • short_month_name
  • days_in_month
  • short_year
  • short_hours
  • ampm
  • not_null
  • sql_date
  • linear_date
  • linear_date_no_time
  • display_date
  • clock

date - the date widget list

Partial Call Graph (max 5 caller/called nodes):
%3 test_sql_date sql_date (test acs-templating) template::util::date::get_property template::util::date::get_property test_sql_date->template::util::date::get_property calendar::to_sql_datetime calendar::to_sql_datetime (public) calendar::to_sql_datetime->template::util::date::get_property packages/calendar/www/cal-item-new.tcl packages/calendar/ www/cal-item-new.tcl packages/calendar/www/cal-item-new.tcl->template::util::date::get_property packages/edit-this-page/www/etp-edit.tcl packages/edit-this-page/ www/etp-edit.tcl packages/edit-this-page/www/etp-edit.tcl->template::util::date::get_property template::data::to_sql::date template::data::to_sql::date (public) template::data::to_sql::date->template::util::date::get_property template::data::validate::textdate template::data::validate::textdate (public) template::data::validate::textdate->template::util::date::get_property

Testcases:
sql_date

template::util::date::init (public)

 template::util::date::init

Sets up some initial variables and other conditions to facilitate the data structure template::util::date working properly and completely.

Partial Call Graph (max 5 caller/called nodes):
%3 packages/acs-templating/tcl/date-init.tcl packages/acs-templating/ tcl/date-init.tcl template::util::date::init template::util::date::init packages/acs-templating/tcl/date-init.tcl->template::util::date::init

Testcases:
No testcase defined.

template::util::date::monthName (public)

 template::util::date::monthName month length

Return the specified month name (short or long)

Parameters:
month
length

Partial Call Graph (max 5 caller/called nodes):
%3 template::util::date::get_property template::util::date::get_property (public) template::util::date::monthName template::util::date::monthName template::util::date::get_property->template::util::date::monthName template::widget::monthFragment template::widget::monthFragment (public) template::widget::monthFragment->template::util::date::monthName

Testcases:
No testcase defined.

template::util::date::now (public)

 template::util::date::now

Create a new Date object for the current date and time.

Partial Call Graph (max 5 caller/called nodes):
%3 test_sql_date sql_date (test acs-templating) template::util::date::now template::util::date::now test_sql_date->template::util::date::now template::util::date::set_property template::util::date::set_property (public) template::util::date::set_property->template::util::date::now

Testcases:
sql_date

template::util::date::now_min_interval (public)

 template::util::date::now_min_interval [ -clock clock ]

Create a new Date object for the current date and time with the default interval for minutes

Switches:
-clock (optional)
time in seconds, if not specified, it uses current time
Author:
Walter McGinnis <wtem@olywa.net>
Created:
2002-01-06

Partial Call Graph (max 5 caller/called nodes):
%3 test_date_minute_interval date_minute_interval (test acs-templating) template::util::date::now_min_interval template::util::date::now_min_interval test_date_minute_interval->template::util::date::now_min_interval

Testcases:
date_minute_interval

template::util::date::now_min_interval_plus_hour (public, deprecated)

 template::util::date::now_min_interval_plus_hour [ -clock clock ]
Deprecated. Invoking this procedure generates a warning.

Create a new Date object for the current date and time plus one hour with the default interval for minutes.

Switches:
-clock (optional)
time in seconds, if not specified, it uses current time Deprecated: as of 2019-04-25, no upstream code is making use of this proc and more generic alternatives exist.
Author:
Walter McGinnis <wtem@olywa.net>
Created:
2002-01-06

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::date::set_property (public)

 template::util::date::set_property what date value

Replace a property in a list created by a date widget.

Parameters:
what - name of the property (see source for allowed values)
date - the date list
value - the new value
Returns:
the modified list

Partial Call Graph (max 5 caller/called nodes):
%3 calendar::from_sql_datetime calendar::from_sql_datetime (public) template::util::date::set_property template::util::date::set_property calendar::from_sql_datetime->template::util::date::set_property template::data::transform::date template::data::transform::date (public) template::data::transform::date->template::util::date::set_property template::util::date::acquire template::util::date::acquire (public) template::util::date::acquire->template::util::date::set_property template::util::date::add_time template::util::date::add_time (public) template::util::date::add_time->template::util::date::set_property template::util::date::from_ansi template::util::date::from_ansi (public) template::util::date::from_ansi->template::util::date::set_property

Testcases:
No testcase defined.

template::util::date::today (public)

 template::util::date::today

Create a new Date object for the current date.

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::date::unpack (public)

 template::util::date::unpack date

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

Parameters:
date

See Also:
  • template::util::date::from_ans

Partial Call Graph (max 5 caller/called nodes):
%3 template::util::date::get_property template::util::date::get_property (public) template::util::date::unpack template::util::date::unpack template::util::date::get_property->template::util::date::unpack template::util::date::validate template::util::date::validate (public) template::util::date::validate->template::util::date::unpack

Testcases:
No testcase defined.

template::util::date::validate (public)

 template::util::date::validate date error_ref

Validate a date object.

Parameters:
date
error_ref
Returns:
1 if the object is valid, 0 otherwise. Set the error_ref variable to contain an error message, if any.

Partial Call Graph (max 5 caller/called nodes):
%3 test_validate_date validate_date (test acs-templating) template::util::date::validate template::util::date::validate test_validate_date->template::util::date::validate packages/calendar/www/cal-item-new.tcl packages/calendar/ www/cal-item-new.tcl packages/calendar/www/cal-item-new.tcl->template::util::date::validate packages/news/www/preview.tcl packages/news/ www/preview.tcl packages/news/www/preview.tcl->template::util::date::validate template::data::validate::date template::data::validate::date (public) template::data::validate::date->template::util::date::validate template::data::validate::time_of_day template::data::validate::time_of_day (public) template::data::validate::time_of_day->template::util::date::validate template::data::validate::timestamp template::data::validate::timestamp (public) template::data::validate::timestamp->template::util::date::validate

Testcases:
validate_date

template::util::leadingPad (public, deprecated)

 template::util::leadingPad string size
Deprecated. Invoking this procedure generates a warning.

Pad a string with leading zeros Deprecated: please use the new and more general 'ad_pad'.

Parameters:
string
size

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::leadingTrim (public, deprecated)

 template::util::leadingTrim value
Deprecated. Invoking this procedure generates a warning.

Trim the leading zeros from the value, but preserve the value as "0" if it is "00"

Parameters:
value

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::negative (public)

 template::util::negative value

Check if a value is less than zero, but return false if the value is an empty string.

Parameters:
value

Partial Call Graph (max 5 caller/called nodes):
%3 test_util_negative util_negative (test acs-templating) template::util::negative template::util::negative test_util_negative->template::util::negative

Testcases:
util_negative

template::util::textdate (public)

 template::util::textdate command [ args... ]

Dispatch procedure for the textdate object

Parameters:
command

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::textdate::create (public)

 template::util::textdate::create [ textdate ]

Build a textdate datatype structure, which is just the string itself for this simple type.

Parameters:
textdate (optional)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::textdate_localized_format (public)

 template::util::textdate_localized_format

Gets the localized format for the textdate widget

Partial Call Graph (max 5 caller/called nodes):
%3 template::data::transform::textdate template::data::transform::textdate (public) template::util::textdate_localized_format template::util::textdate_localized_format template::data::transform::textdate->template::util::textdate_localized_format template::data::validate::textdate template::data::validate::textdate (public) template::data::validate::textdate->template::util::textdate_localized_format template::widget::textdate template::widget::textdate (public) template::widget::textdate->template::util::textdate_localized_format

Testcases:
No testcase defined.

template::util::time_of_day::get_property (public)

 template::util::time_of_day::get_property what date

Replace a property in a list created by a time_of_day widget. It's the same as the date one. This is needed by the form builder to support explicit to_sql element modifiers.

Parameters:
what
date

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::time_of_day::set_property (public)

 template::util::time_of_day::set_property what date value

Get a property in a list created by a time_of_day widget. It's the same as the date one. This is needed by the form builder to support explicit from_sql element modifiers.

Parameters:
what
date
value

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::timestamp::get_property (public)

 template::util::timestamp::get_property what date

Replace a property in a list created by a timestamp widget. It's the same as the date one. This is needed by the form builder to support explicit to_sql element modifiers.

Parameters:
what
date

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::timestamp::set_property (public)

 template::util::timestamp::set_property what date value

Get a property in a list created by a timestamp widget. It's the same as the date one. This is needed by the form builder to support explicit from_sql element modifiers.

Parameters:
what
date
value

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::widget::ampmFragment (public)

 template::widget::ampmFragment element_reference fragment size type \
    value [ mode ] [ tag_attributes ]

Create a widget that shows the am/pm selection

Parameters:
element_reference
fragment
size
type
value
mode (defaults to "edit")
tag_attributes (optional)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::widget::date (public)

 template::widget::date element_reference tag_attributes

Create a date entry widget according to a format string The format string should contain the following fields, separated by / \ - : . or whitespace:

stringmeaning
YYYY4-digit year
YY2-digit year
MM2-digit month
MONmonth name, short (i.e. "Jan")
MONTHmonth name, long (i.e. "January")
DDday of month
HH1212-hour hour
HH2424-hour hour
MIminutes
SSseconds
AMam/pm flag
Any format field may be followed by "t", in which case a text widget will be used to represent the field. the array in range_ref determines interval ranges; the keys are the date fields and the values are in form {start stop interval}

Parameters:
element_reference
tag_attributes

Partial Call Graph (max 5 caller/called nodes):
%3 template::widget::time_of_day template::widget::time_of_day (public) template::widget::date template::widget::date template::widget::time_of_day->template::widget::date template::widget::timestamp template::widget::timestamp (public) template::widget::timestamp->template::widget::date

Testcases:
No testcase defined.

template::widget::dateFragment (public)

 template::widget::dateFragment element_reference fragment size type \
    value [ mode ] [ tag_attributes ]

Create an input widget for the given date fragment If type is "t", uses a text widget for the fragment, with the given size. Otherwise, determines the proper widget based on the element flags, which may be text or a picklist.

Parameters:
element_reference
fragment
size
type
value
mode (defaults to "edit")
tag_attributes (optional)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::widget::h5date (public)

 template::widget::h5date element_reference tag_attributes

Implements the HTML 5 input type "date". Supported element parameters: "-min" and "-max": for setting minimum and maximum dates that can be chosen by the user. If used, the condition min <= value <= max must be met. (Format = YYYY-MM-DD) "-step": number of days jumped each time the date is incremented. Value must be an integer Parameters supplied this way will supersede same-named parameters supplied through the "-html" switch. This widget also adds the attribute "pattern" as fallback for browsers which do not support input type="date".

Parameters:
element_reference
tag_attributes

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::widget::h5time (public)

 template::widget::h5time element_reference tag_attributes

Implements the HTML 5 input type "time". Supported element parameters: "-min" and "-max": for setting minimum and maximum times that can be chosen by the user. If used, the condition min <= value <= max must be met. (Format = "hh:mm" or "hh:mm:ss" if parameter "-step" is present) "-step": integer value that equates to the number of seconds you want to increment by Parameters supplied this way will supersede same-named parameters supplied through the "-html" switch. This widget also adds the attribute "pattern" as fallback for browsers which do not support input type="time".

Parameters:
element_reference
tag_attributes

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::widget::monthFragment (public)

 template::widget::monthFragment element_reference fragment size type \
    value [ mode ] [ tag_attributes ]

Create a month entry widget with short or long month names.

Parameters:
element_reference
fragment
size
type
value
mode (defaults to "edit")
tag_attributes (optional)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::widget::numericRange (public)

 template::widget::numericRange name interval_def size [ value ] \
    [ tag_attributes ]

Create an HTML fragment to display a numeric range widget interval_def is in form { start stop interval }

Parameters:
name
interval_def
size
value (optional)
tag_attributes (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 template::widget::dateFragment template::widget::dateFragment (public) template::widget::numericRange template::widget::numericRange template::widget::dateFragment->template::widget::numericRange template::widget::numericrange template::widget::numericrange (public) template::widget::numericrange->template::widget::numericRange

Testcases:
No testcase defined.

template::widget::numericrange (public)

 template::widget::numericrange element_reference tag_attributes

Widget proc usable with ad_form to display a numeric range widget. Need to define interval_def as {interval_def {start end step}}

Parameters:
element_reference
tag_attributes

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::widget::textdate (public)

 template::widget::textdate element_reference tag_attributes

Implements the textdate widget.

Parameters:
element_reference
tag_attributes

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::widget::time_of_day (public)

 template::widget::time_of_day element_reference tag_attributes

Render a time_of_day widget. Default is the localized version.

Parameters:
element_reference
tag_attributes

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::widget::timestamp (public)

 template::widget::timestamp element_reference tag_attributes

Render a timestamp widget. Default is the localized version.

Parameters:
element_reference
tag_attributes

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.
[ show source ]