• 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.65 2024/09/11 06:15:48 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 (required)
See Also:

Testcases:
template_date_api

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 (required)
See Also:

Testcases:
template_date_api

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

 template::data::from_sql::timestamp value

Reads an ANSI timestamp as a templating date object.

Parameters:
value (required)
See Also:

Testcases:
template_date_api

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

 template::data::to_sql::date value

Converts a templating date object into a SQL date.

Parameters:
value (required)
See Also:

Testcases:
template_date_api

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 (required)
See Also:

Testcases:
template_date_api

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

 template::data::to_sql::timestamp value

Converts a templating date object into a SQL timestamp.

Parameters:
value (required)
See Also:

Testcases:
template_date_api

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

 template::data::transform::date element_ref

Collect a Date object from the form.

Parameters:
element_ref (required)

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 (required)

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 (required)

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 (required)

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 (required)
Reference variable to the submitted value.
message_ref (required)
Reference variable for returning an error message.
Returns:
True (1) if valid, false (0) if not.

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 (required)
Reference variable to the submitted value.
message_ref (required)
Reference variable for returning an error message.
Returns:
True (1) if valid, false (0) if not.

Testcases:
No testcase defined.

template::util::date (public)

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

Dispatch procedure for the date object

Parameters:
command (required)

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 (required)
value (optional)

Testcases:
template_date_api

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

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 (required)
date2 (required)

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 (optional, defaults to "DD MONTH YYYY")

Testcases:
template_date_api

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

 template::util::date::daysInMonth month [ year ]
Parameters:
month (required)
year (optional, 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:

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 (required)

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 (required)
Date in full ANSI format YYYY-MM-DD HH24:MI:SS (time portion is optional).
format (optional, 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

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 (required)
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 (required)
the date widget list

Testcases:
sql_date, template_date_api

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.

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 (required)
length (required)

Testcases:
No testcase defined.

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

 template::util::date::now

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

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

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:

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 (required)
name of the property (see source for allowed values)
date (required)
the date list
value (required)
the new value
Returns:
the modified list

Testcases:
template_date_api

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

 template::util::date::today

Create a new Date object for the current date.

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 (required)
See Also:
  • template::util::date::from_ans

Testcases:
template_date_api

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

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

Validate a date object.

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

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 (required)
size (required)
See Also:

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 (required)
See Also:

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 (required)

Testcases:
util_negative

template::util::textdate (public)

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

Dispatch procedure for the textdate object

Parameters:
command (required)

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)

Testcases:
No testcase defined.

template::util::textdate_localized_format (public)

 template::util::textdate_localized_format

Gets the localized format for the textdate widget

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 (required)
date (required)

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 (required)
date (required)
value (required)

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 (required)
date (required)

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 (required)
date (required)
value (required)

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 (required)
fragment (required)
size (required)
type (required)
value (required)
mode (optional, defaults to "edit")
tag_attributes (optional)

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 (required)
tag_attributes (required)

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 (required)
fragment (required)
size (required)
type (required)
value (required)
mode (optional, defaults to "edit")
tag_attributes (optional)

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 (required)
tag_attributes (required)

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 (required)
tag_attributes (required)

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 (required)
fragment (required)
size (required)
type (required)
value (required)
mode (optional, defaults to "edit")
tag_attributes (optional)

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 (required)
interval_def (required)
size (required)
value (optional)
tag_attributes (optional)

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 (required)
tag_attributes (required)

Testcases:
No testcase defined.

template::widget::textdate (public)

 template::widget::textdate element_reference tag_attributes

Implements the textdate widget.

Parameters:
element_reference (required)
tag_attributes (required)

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 (required)
tag_attributes (required)

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 (required)
tag_attributes (required)

Testcases:
No testcase defined.
[ show source ]