Template:Earth-date/doc

Jump to navigation Jump to search

Purpose[edit source]

This template formats any valid Gregorian calendar date into either of the two standardized, properly formatted Federation calendar Terran dates.

Usage[edit source]

Syntax[edit source]

This template has three parameters, all of which are optional:

{{earth-date | date to be formatted | full month name | year link }}

  • date to be formatted parameter is a target date (optional) to be formatted.
    If no date is specified, the template emits the current date.
    For example, {{earth-date}} produces 04 Oct 2024.
    If a date is provided, but is not recognized as a one, the template will return an "Invalid time." error. Most dates will however be recognized as such, including all the formats typically used on 21st century earth. Numerous variations thereof are also supported, including abbreviated or lower-case month names; ordinal "st", "nd", "rd", "th"; extraneous white space; missing comma, etc.
    Notes:
    • Some dates are converted even if they are not real dates, and some dates are not converted even though they are real dates. See known issues below.
    • Only dates within the range 1 January 1000 and 31 December 9999 are supported. Dates with two-digit years will have the years from 1970 to 2069. Other dates outside the range 1000–9999 will be treated as if the second parameter were "none".
    • when using month numbers in numeric, the valid formats are MM/DD/YYYY, DD-MM-YYYY, DD.MM.YYYY, YYYY/MM/DD, YYYY-MM-DD, MM/DD/YY, YY-MM-DD, DD.MM.YY, the invalid formats are DD/MM/YYYY, MM-DD-YYYY, MM.DD.YY, YYYY.MM.DD, MM.DD.YYYY, DD-MM-YY, YY/MM/DD, DD/MM/YY, YY.MM.DD
  • full month name controls the format in which the month result is to be emitted. The recognized value for the second parameter is:
    full which forces the month's name to be spelled out (e.g. 31 December 2271 ).
    This is used for more formally written applications, whereas the default three letter abbreviation is the standard way of writing the date.
    The default abbreviated format makes tables and columnar lists of dates appear uniform as well as taking up less space in text.
    Notes:
    • This parameter can only be used when a target date to be formatted parameter is used.
    • The word full must be spelled out.
    • The parameter is not case-sensitive.
    • If used with the third year link  parameter full can be in either the second or third position within the parameter string.
  • year link controls whether or not the year result is to be emitted as a link to the article for that year. The recognized value for the third parameter is:
    link which converts the year number an article link for that year (e.g. 19 Jun 2271 ).
    This is used for more formally written applications, whereas the default three letter abbreviation is the standard way of writing the date.
    The default abbreviated format makes tables and columnar lists of dates appear uniform as well as taking up less space in text.
    Notes:
    • This parameter can only be used when a target date to be formatted parameter is used.
    • The word link must be spelled out.
    • The parameter is not case-sensitive.
    • If used with the third full month name  parameter link can be in either the second or third position within the parameter string.

Examples[edit source]

Format Input Output
Target date with year only
(defaults to current day &
month of target year)
{{earth-date|2006}} 04 Oct 2006
{{earth-date|2006|full}} 04 October 2006
{{earth-date|2006|link}} 04 Oct 2006
{{earth-date|2006|full|link}} 04 October 2006
{{earth-date|2006|link|full}} 04 October 2006
{{earth-date|2006|lorem ipsum}} 04 Oct 2006
Target date without year
(defaults to current year)
{{earth-date|4 August}} 04 Aug 2024   (defaults to current year)
{{earth-date|Aug 4}} 04 Aug 2024   (defaults to current year)
{{earth-date|}} 04 Oct 2024   (defaults to current date)
{{earth-date||}} 04 Oct 2024   (defaults to current date)
{{earth-date|full}} Error: Invalid time. Error: Invalid time. Error: Invalid time.
{{earth-date|link}} Error: Invalid time. Error: Invalid time. Error: Invalid time.
{{earth-date|lorem ipsum}} Error: Invalid time. Error: Invalid time. Error: Invalid time.
Target date with valid YMD date {{earth-date|2006-08-04}} 04 Aug 2006
{{earth-date|Aug 4, 2006}} 04 Aug 2006
{{earth-date|Aug 4 2006}} 04 Aug 2006
{{earth-date|August 4th, 2006}} 04 Aug 2006
{{earth-date|4th August 2006}} 04 Aug 2006
{{earth-date|2006/8/4}} 04 Aug 2006
{{earth-date|2006-08}} 01 Aug 2006   (defaults to first day of month)
{{earth-date|2006-Aug}} 01 Aug 2006   (defaults to first day of month)
{{earth-date|August 2006}} 01 Aug 2006   (defaults to first day of month)
Link parameter {{earth-date|August 4, 2006|link}} 04 Aug 2006
{{earth-date|August 4, 2006|link|lorem ipsum}} 04 Aug 2006
{{earth-date|August 4, 2006|lorem ipsum|link}} 04 Aug 2006
{{earth-date|August 4, 2006|link|full}} 04 August 2006
{{earth-date|August 4, 2006|full|link}} 04 August 2006
Full parameter {{earth-date|August 4, 2006|full}} 04 August 2006
{{earth-date|August 4, 2006|full|lorem ipsum}} 04 August 2006
{{earth-date|August 4, 2006|lorem ipsum|full}} 04 August 2006
{{earth-date|August 4, 2006|full|link}} 04 August 2006
{{earth-date|August 4, 2006|link|full}} 04 August 2006

Known issues[edit source]

Out-of-range values are "fixed"
  • The PHP library, that this template ultimately depends on, converts out-of-range values to the next-best in-range values. As a result, some date-like values that are not actually valid dates get converted anyway. These include...
    • all dates with zero day-of-the-month. Such a "zero-th" day of a month gets converted into the last day of the previous month.
      For example, {{date|June 0, 2006}} results in 31 May 2006.
      Similarly, {{date|0 January 2006}} becomes 31 December 2005.
    • all dates with day-number values that exceed the number of days in the specified month cause the date to be incremented into the next month.
      For example, {{date|31 November 2008}} results in 1 December 2008, since November has only 30 days.
      Similarly, {{date|February 29, 2007}} results in 1 March 2007, since 2007 was not a leap year.
      Note: Due to a parser peculiarity in the PHP library, 'December 32' and '32 December' are treated differently, and the latter results in an error (which causes this template to emit it unchanged), and only the former "overflows" into the next month.
Non-Gregorian dates are treated as Gregorian
  • The PHP library that this template ultimately depends on assumes that all dates, irrespective of context, are Gregorian calendar dates. Consequently:
    • some dates that would be valid in a non-Gregorian context are treated as out-of-range dates and converted to the next-best in-range values. For example, {{date|30 February 1712}} results in 1 March 1712 because – even though 30 February 1712 is a valid date in the Swedish calendar – February 1712 had only 29 days in the Gregorian calendar.
    • ten dates are not reformatted. These are 29 February & 1 March of the years 1000, 1100, 1300, 1400, 1500. The cause of this is the same as that of the Swedish 30 February 1712.
    • some dates that would not be valid in some contexts are converted normally. For example, 29 February 1912 or 1 February 1918 are not valid in a Russian context, but perfectly valid in the Gregorian one.

See also[edit source]