8 <:date:>

<:date [fmt] [date] 
     [lang] [to_zone] [from_zone]:>

Displays a string representation of a date/time object. This is an STML tag equivalent of the DateString function in the Skunk pylibs Date module.

Note that all attribute arguments to this tag are optional.

fmt must be a string, and specifies the format in which to display the date/time. If not specified, fmt defaults to the Date module's default format, which is the ISO format yyyy-mm-dd hh:mi:ss.

The fmt string may contain any combination of the following format elements. Anything not recognized as a format is included in the output as static text:

yyyy
four-digit year
yy
two-digit year
mm
two-digit month
dd
two-digit day
hh24
24-hour hour
hh12
12-hour hour
hh
equivalent to hh24
mi
or min minutes
SS
seconds

For all of the above, leading zeroes are included as necessary: ``01'' instead of 1, etc. However, if the format element is in UPPERCASE, leading zeroes are not included: ``MM'' -> ``1'', ``mm'' -> ``01''.

mon
abbreviated name of month
month
full name of month
dy
abbreviated weekday name
day
full weekday name
am or pm
whether time is AM or PM

For all of the above, if the element is in UPPERCASE, the result will be in ALL CAPS: ``MONTH'' -> ``JANUARY''. If the element is Initcap, the result will be initcapped: ``Month'' -> ``January''. Any other combination of case will be considered lowercase: ``month'' or ``moNth'' -> ``january''.

date
is a Python expression resulting in a date/time (strings are not allowed). If not specified, it defaults to the current local date/time of the machine.

lang
must be a string specifying the language in which to format the date/time, using the Skunk convention of 'eng' 'esp' 'por' for English, Spanish, and Portuguese, respectively. If not given, it defaults to 'eng'.

to_zone
is a timezone argument, meaning, ``Please convert the date argument to this timezone before displaying.'' It defaults to the SkunkWeb server machine's local timezone. See the Date module for a full discussion of timezone support. (Note: This argument formerly had the name timezone. STML still understands the old argument name. If you specify both to_zone and a timezone argument, STML will use to_zone and ignore timezone.)

from_zone
is a timezone argument, meaning, ``Please convert the date argument from this timezone into the SkunkWeb server machine's local timezone before doing anything else.'' See the Date module for a full explanation. Note: This argument used to be named srctimezone. STML still understands the old argument name. If you specify both from_zone and a srctimezone argument, srctimezone will be ignored.

Here are some examples, if the current date is 2000-08-01 20:34:56 (a Tuesday), and your server is running on Eastern Daylight Time, which is four hours behind UTC (Greenwich Time). Each tag is followed by the output which would be displayed:

<:date:> 
2000-08-01 20:34:56

<:date "dd mon yy":>
01 aug 00

<:date "hh12:mi am":>  
08:34 pm

<:date "HH12:mi am":>  
8:34 pm

<:date "hh12:mi am" to_zone="UTC":>  
12:34 am

<:date "Month DD, yyyy, hh12:mi am" to_zone="UTC":>  
August 2, 2000, 12:34 am

<:date "DD month yyyy, hhhmi" lang="esp" to_zone="UTC":>  
2 agosto 2000 00h34

To do the equivalent in Python components, if unspecified arguments are None, is:

import Date
temp_date = Date.Convert ( date, to_zone or 'LOCAL', from_zone or 'LOCAL' )
print Date.DateString ( temp_date, fmt, lang )