192 lines
5.9 KiB
XML
192 lines
5.9 KiB
XML
|
<section id='&s2.idroot;siteapi.core1.dateformats'>
|
||
|
<title>Date Formats</title>
|
||
|
<para>The <function>Date</function> class has a method <function>date_format()</function> and its subclass <function>DateTime</function> adds the method <function>time_format()</function>. There's also a <function>month_format()</function> on objects dealing with only a month. All these methods take an optional format string which can be either a named format or a custom format string. If no format is provided, a default sensible version is used. The default is indicated in the table below.</para>
|
||
|
|
||
|
<section id='&s2.idroot;siteapi.core1.dateformat.named'>
|
||
|
<title>Named Date Formats</title>
|
||
|
|
||
|
<para>The following named date formats are supported and localized for internationalization. The English representation is shown only as an example.</para>
|
||
|
|
||
|
<informaltable frame='all'>
|
||
|
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
|
||
|
<colspec align="left" />
|
||
|
<thead>
|
||
|
<row>
|
||
|
<entry>Method</entry>
|
||
|
<entry>Named Format</entry>
|
||
|
<entry>Default?</entry>
|
||
|
<entry>English Format</entry>
|
||
|
<entry>English Result</entry>
|
||
|
</row>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<row>
|
||
|
<entry>date_format</entry>
|
||
|
<entry>short</entry>
|
||
|
<entry>X</entry>
|
||
|
<entry>%%m%%/%%d%%/%%yy%%</entry>
|
||
|
<entry>2/5/80</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>date_format</entry>
|
||
|
<entry>med</entry>
|
||
|
<entry></entry>
|
||
|
<entry>%%mon%%. %%dayord%%, %%yyyy%%</entry>
|
||
|
<entry>Feb. 5th, 1980</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>date_format</entry>
|
||
|
<entry>med_day</entry>
|
||
|
<entry></entry>
|
||
|
<entry>%%da%%, %%mon%%. %%dayord%%, %%yyyy%%</entry>
|
||
|
<entry>Tue, Feb. 5th, 1980</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>date_format</entry>
|
||
|
<entry>long</entry>
|
||
|
<entry></entry>
|
||
|
<entry>%%month%% %%dayord%%, %%yyyy%%</entry>
|
||
|
<entry>February 5th, 1980</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>date_format</entry>
|
||
|
<entry>long_day</entry>
|
||
|
<entry></entry>
|
||
|
<entry>%%day%%, %%month%% %%dayord%%, %%yyyy%%</entry>
|
||
|
<entry>Tuesday, February 5th, 1980</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>time_format</entry>
|
||
|
<entry>short</entry>
|
||
|
<entry>X</entry>
|
||
|
<entry>%%hh%%:%%min%% %%a%%m</entry>
|
||
|
<entry>12:34 am</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>month_format</entry>
|
||
|
<entry>short</entry>
|
||
|
<entry></entry>
|
||
|
<entry>%%m%%/%%yy%%</entry>
|
||
|
<entry>04/03</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>month_format</entry>
|
||
|
<entry>med</entry>
|
||
|
<entry></entry>
|
||
|
<entry>%%mon%% %%yyyy%%</entry>
|
||
|
<entry>Apr 2003</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>month_format</entry>
|
||
|
<entry>long</entry>
|
||
|
<entry>X</entry>
|
||
|
<entry>%%month%% %%yyyy%%</entry>
|
||
|
<entry>April 2003</entry>
|
||
|
</row>
|
||
|
|
||
|
</tbody>
|
||
|
</tgroup>
|
||
|
</informaltable>
|
||
|
|
||
|
</section>
|
||
|
|
||
|
<section id='&s2.idroot;siteapi.core1.dateformat.custom'>
|
||
|
<title>Custom Date Formats</title>
|
||
|
|
||
|
<para>If you're making a style for yourself and don't care about keeping the date formats generic for internationalization, you can construct your own date format string with interpolated variables which you surround in double percent signs.</para>
|
||
|
|
||
|
<informaltable frame='all'>
|
||
|
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
|
||
|
<colspec align="left" />
|
||
|
<thead>
|
||
|
<row>
|
||
|
<entry>Variable</entry>
|
||
|
<entry>Description</entry>
|
||
|
</row>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<row>
|
||
|
<entry>m</entry>
|
||
|
<entry>Month, 1-12.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>mm</entry>
|
||
|
<entry>Month, 01-12.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>d</entry>
|
||
|
<entry>Day, 1-31.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>dd</entry>
|
||
|
<entry>Day, 01-31.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>yy</entry>
|
||
|
<entry>Year, two digits.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>yyyy</entry>
|
||
|
<entry>Year, four digits.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>mon</entry>
|
||
|
<entry>Short month name, translated. (English: Jan, Feb, …)</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>month</entry>
|
||
|
<entry>Long month name, translated. (English: January, February, …)</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>da</entry>
|
||
|
<entry>Short day of week, translated. (English: Sun, Mon, …)</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>day</entry>
|
||
|
<entry>Long day of week, translated. (English: Sunday, Monday, …)</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>dayord</entry>
|
||
|
<entry>Ordinal day of month, translated. (English: 1st, 2nd, 3rd, …)</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>H</entry>
|
||
|
<entry>Hour, 0-23.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>HH</entry>
|
||
|
<entry>Hour, 00-23.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>h</entry>
|
||
|
<entry>Hour, 1-12.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>hh</entry>
|
||
|
<entry>Hour, 01-12.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>min</entry>
|
||
|
<entry>Minute, 00-59.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>sec</entry>
|
||
|
<entry>Second, 00-59.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>a</entry>
|
||
|
<entry>"a" for am, "p" for pm.</entry>
|
||
|
</row>
|
||
|
<row>
|
||
|
<entry>A</entry>
|
||
|
<entry>"A" for am, "P" for pm.</entry>
|
||
|
</row>
|
||
|
|
||
|
</tbody>
|
||
|
</tgroup>
|
||
|
</informaltable>
|
||
|
|
||
|
</section>
|
||
|
|
||
|
</section>
|