User:Patrick/date type

From semanticweb.org
Jump to: navigation, search

This somewhat experimental datatype parses dates in various formats. It internally stores the date as the number of seconds since 1970 and displays dates in the international standard ISO8601 YYYY-MM-DDTHH:MM:SS format.


Contents

[edit] Date Issues

Internally it uses the PHP strtotime function to parse the date. It does not use your date/time preferences in MediaWiki.

Possible issues: timezones, and locale-specific date formats (e.g. mm/dd/yy versus dd/mm/yy).

See improving date type.

[edit] Date Ranges

In SMW 0.5, the range is only from 1901-12-14 to 2038-1-19. This limitation comes from PHP (the timestamp is a 32-bit signed number).

Minimum date/time: <ask headers=hide>ontoworld.org:+ontoworld.org:Date range+warning.pngThe date "+" was not understood. *warning.pngThe date "*" was not understood.</ask>

which is

   2^31 seconds = 2,147,483,648 seconds

before 1 Jan 1970, 01:00:00.

Maximum date/time: <ask headers=hide>ontoworld.org:+ontoworld.org:Date range+warning.pngThe date "+" was not understood.*warning.pngThe date "*" was not understood.</ask>

which is this amount of time after 1 Jan 1970, 00:59:59, .

        68 years is 17 * 1461 days = 24837 days = 2,145,916,800 seconds,
        so 1,566,848 seconds remain,
        Subtracting 18 days, 11,648 seconds remain,
        which is 3 hours, 14 minutes, and 8 seconds.

See also Date range.

Thus this type is unsuitable for many historic dates!

See also [1], [2].

[edit] Date Comparisons

Comparisons between an attribute value and a date outside the range are always considered true (!):

*1 <ask>[[date of birth:=+]]</ask>
*2 <ask>[[date of birth:=<1832-12-31]]</ask>
*3 <ask>[[date of birth:=1832-12-31]]</ask>
*4 <ask>[[date of birth:=>1832-12-31]]</ask>
*5 <ask>[[date of birth:=<1901-12-31]]</ask>
*6 <ask>[[date of birth:=1901-12-31]]</ask>
*7 <ask>[[date of birth:=>1901-12-31]]</ask>

gives:

1 <ask>+</ask>

2 <ask><1832-12-31warning.png"&lt;1832-12-31" cannot be used as a page name in this wiki.</ask>

3 <ask>1832-12-31</ask>

4 <ask>>1832-12-31warning.png"&gt;1832-12-31" cannot be used as a page name in this wiki.</ask>

5 <ask><1901-12-31warning.png"&lt;1901-12-31" cannot be used as a page name in this wiki.</ask>

6 <ask>1901-12-31</ask>

7 <ask>>1901-12-31warning.png"&gt;1901-12-31" cannot be used as a page name in this wiki.</ask>

[edit] Representing Date Parts

Although a YYYY-MM-DD date string contains a calendar date and year, you can't derive these or query on them in SMW 0.5. Instead you can create additional attributes or relations for them, and use a date template in articles that fills them in.

For years, we can choose between a relation and an attribute, or annotate both. An attribute of type integer has the advantage that we can do numeric sorting and comparisons. A relation has the advantage that we get links to year pages, but sorting is alphabetic (which is the same as numeric within the period 1000 - 9999). Selection based on a relation only allows equality, no inequality.

[edit] Date Tests

These values in annotations give the dates shown in the factbox: Please move these to a separate Testpage

yesterday today tomorrow monday tuesday wednesday thursday friday saturday sunday 11-12-3 111-12-4 38-1-18 38-1-19 38-1-20 21-12-5 31-12-5 41-12-5 69-12-31 70-1-1 71-12-5 81-12-5 91-12-5

See also e.g. Attribute:Date of birth, Attribute:Birthday, Attribute:Astrological sign


Personal tools
Namespaces

Variants
Actions
Navigation
services
Toolbox