Gebruiker:Patrick/tijd

Uit Wikipedia, de vrije encyclopedie

ISO 8601-varianten[bewerken | brontekst bewerken]

Een datum wordt genoteerd van meest naar minst significant onderdeel, dus eerst het jaartal (YYYY), dan de maand (MM=01,02,...,12), de dag (DD=01,02,...,31), en het tijdstip (hh:mm:ss) in 24-uursnotatie met een T tussen de dag en het tijdstip. Dit is dus in de vorm "YYYYMMDDThhmmss". Chronologische volgorde van tijdsaanduidingen komt overeen met de lexicografische volgorde.

Mogelijke conventies:

  • Zolang de T blijft staan kunnen aan het begin en het eind delen worden weggelaten. Eerste kerstdag is dan bijvoorbeeld 1225T.
  • De T is onnodig, alleen aan het eind kan een deel worden weggelaten.

Zonder T zowel aan het begin en het eind delen kunnen weglaten zou betekenen dat 1207 kan zijn:

  • het jaar 1207
  • 7 dec
  • de 12e, 7:00
  • 12:07

Hieronder gaat het over de 2e conventie (3.1.3.7 representation with reduced precision: abbreviation of a date and time representation (3.1.3.2) by omission of lower order time scale components (3.1.3.3)). De T wordt weggelaten. Een notatie kan zowel een halfopen tijdsinterval (met wel het begintijdstip, maar niet het eindtijdstip) aangeven als het eerste tijdstip ervan; dat moet dus erbij gezegd worden (hier i resp. s). De notatie "-" tussen tijdsintervallen betekent hierna tot en met, en tussen tijdstippen tot en zonder.

  • i2 is millennium 2, i20-29, s20-30, i200-299, s200-300, i2000-2999, s2000-3000
  • i20 is eeuw 20 (of wat nadrukkelijker "eeuw nummer 20", niet te verwarren met de 20e eeuw), i200-209, s200-300, i2000-2099, s2000-2100
  • i202 is decennium 202, i2020-2029, s2020-2030 (jaren 2020)
  • i2021 is een jaar, i202101-202112, s202101-202201, i20210101-20211231, s20210101-20220101, i2021010100-2021123123, s2021010100-2022010100
  • i202103 is een maand
  • i20210309 is een dag
  • i2021030918 is een uur
  • i202103091842 is een minuut
  • i20210309184251 is een seconde

Of links van het streepje een tijdsinterval of een tijdstip wordt bedoeld maakt niet uit (mits het hele tijdsinterval niet korter is dan de eerste aanduiding, geínterpreteerd als interval), dus het vierde punt kan beknopter: begin is 2021, eind is i2021, s2022, i202112, i20211231 en i2021123123, en dit kan worden aangevuld met i202112312359 en i20211231235959

Een interval kan ook nog een tijdstip aangeven, maar dan met een zekere onnauwkeurigheid (hierna aangegeven met o): het tijdstip ligt in het interval (een digitale klok doet dit). Een tijdsinterval kan dan geschreven worden met zo'n onnauwkeurigheidsinterval voor en na het streepje. Dan is dus o2021-o2023 niet hetzelfde als o202101-o202312.

OV[bewerken | brontekst bewerken]

Voor daluren/spitsuren en voor de 35-minutenregel en de 6-uurregel zijn van tijdstippen van in- en uitchecken alleen hele minuten van belang: er wordt uitgegaan van een discrete verzameling tijden in hele minuten (die tijdsintervallen van een minuut representeren). In een context waarbij de tijden beperkt zijn tot die op een dag zijn er dus 1440 tijden/minuten, aangeduid met 4 cijfers, van 0000 tot en met 2359, waarbij een 0 als eerste cijfer kan worden weggelaten.

De ochtendspits is 635-854, de middagspits is 1605-1824 (beide 2 uur en 20 minuten, de tweede 9 uur en 30 minuten verschoven t.o.v. de eerste. De daluren ertussen zijn 855-1604 (7 uur en 10 minuten). Bij i-u ≤ 34 is het een overstap, bij i-u ≥ 35 begint een nieuwe reis. Bij verblijf op het beginstation is u-i ≤ 59 vereist.

Hiërarchische indeling van de tijd in perioden[bewerken | brontekst bewerken]

Chronologische volgorde correspondeert met lexicografische volgorde, zowel wanneer we de items YYYY, MM, DD, hh, mm en ss beschouwen, als in het geval van de items Y, Y, Y, Y, MM, DD, hh, mm en ss. Dat verspringen correspondeert met het beginnen van respectievelijk perioden van 1000, 100, 10 en 1 jaar, en een maand, dag, uur, minuut en seconde:

  • De eerste Y is een van de getallen 0 t/m 9, waarvan elk een (ISO-)millennium (periode van 1000 jaar) representeert.
  • Voor elke waarde van de eerste Y representeert YY, met de tweede Y een van de getallen 1 t/m 9, een (ISO-)eeuw (periode van 100 jaar).
  • Voor elke waarde van de eerste YY representeert YYY, met de derde Y een van de getallen 1 t/m 9, een (ISO-)decennium (periode van 10 jaar).
  • Voor elke waarde van de eerste YYY representeert YYYY, met de vierde Y een van de getallen 1 t/m 9, een jaar.
  • Voor elke waarde van YYYY representeert YYYY-MM, met MM een van de met eventuele voorloopnul geschreven getallen 1 t/m 12, een maand.
  • Voor elke waarde van YYYY-MM representeert YYYY-MM-DD, met DD een van de met eventuele voorloopnul geschreven getallen 1 tot en met een maximum dat afhangt van YYYY-MM, een dag.
  • Voor elke waarde van YYYY-MM-DD representeert YYYY-MM-DDThh, met hh een van de met eventuele voorloopnul geschreven getallen 0 t/m 23, een uur.
  • Voor elke waarde van YYYY-MM-DDThh representeert YYYY-MM-DDThh:mm, met mm een van de met eventuele voorloopnul geschreven getallen 0 t/m 59, een minuut.
  • Voor elke waarde van YYYY-MM-DDThh:mm representeert YYYY-MM-DDThh:mm:ss, met ss een van de met eventuele voorloopnul geschreven getallen 0 t/m 59, een seconde.

Het geheel geeft een hiërarchische indeling van een periode van 10.000 jaar in, uiteindelijk, seconden.

Bij de maand en de dag van de maand begint de telling bij 1, en correspondeert het getal dus met het rangnummer in het naasthogere type tijdsinterval. In de andere zeven gevallen is dit niet het geval, en correspondeert het cijfer of de cijfercombinatie met een nummering vanaf 0. Het jaar 2021 representeert in dit systeem bijvoorbeeld jaar nummer 1 in de 10-jarige periode 2020 t/m 2029, 10-jarige periode nummer 2 in de 100-jarige periode 2000 t/m 2099, en 100-jarige periode nummer 0 in de 1000-jarige periode 2000 t/m 2999, die 1000-jarige periode nummer 2 is. In dit systeem en deze zeven gevallen geeft het gebruik van een rangnummer onduidelijkheid ("nulde" periode) of ongemak (de periode aangegeven met nummer 2 is de derde periode). Uitdrukkingen als "twintiger jaren" en vollediger "jaren 2020" voor de periode 2020 t/m 2029 passen goed in dit systeem.

Als men een millennium, eeuw en decennium wil laten beginnen op respectievelijk een 1000-, 100- en 10-voud jaren na 1 januari van het jaar 1 (het begin van de jaartelling), dan zijn deze een jaar verschoven ten opzichte van de bovenstaande typen tijdsinterval van 1000, 100 en 10 jaar, zie millenniumkwestie.

Externe links[bewerken | brontekst bewerken]

Jaar[bewerken | brontekst bewerken]

Code Description Current output
Year
Y 4-digit calender year. 2024
y 2-digit year. 24
L 1 if it's a leap year, 0 if not. 1
o week year 2024

Maand[bewerken | brontekst bewerken]

Code Description Current output
Month
n Month index, not zero-padded. 4
m Month index, zero-padded. 04
M An abbreviation of the month name, in the site language. apr
F The full month name in the site language. april

Dag[bewerken | brontekst bewerken]

Code Description Current output
Day of the month or the year
j Day of the month, not zero-padded. 18
d Day of the month, zero-padded. 18
z Day of the year (January 1 = 0).
To get the ISO day of the year add 1.
108

Week[bewerken | brontekst bewerken]

Week and day of the week
W ISO 8601 week number, zero-padded. 16
N ISO 8601 day of the week (Monday = 1, Sunday = 7). 4
w Number of the day of the week (Sunday = 0, Saturday = 6). 4
D An abbreviation for the day of the week. do
l The full weekday name. donderdag

Tijd[bewerken | brontekst bewerken]

Hour
a "am" during the morning (00:00:00 → 11:59:59), "pm" otherwise (12:00:00 → 23:59:59). am
A Uppercase version of a above. AM
g Hour in 12-hour format, not zero-padded. 4
h Hour in 12-hour format, zero-padded. 04
G Hour in 24-hour format, not zero-padded. 4
H Hour in 24-hour format, zero-padded. 04
Minutes and seconds
i Minutes past the hour, zero-padded. 33
s Seconds past the minute, zero-padded. 22
U Unix time. Seconds since January 1 1970 00:00:00 GMT. 1713414802
Timezone
e Timezone identifier. UTC
I Whether or not the date is in daylight savings time. 0
O Difference to Greenwich time (GMT) +0000
P Difference to Greenwich time (GMT), with colon +00:00
T Timezone abbreviation. UTC
Z Timezone offset in seconds. 0
Miscellaneous
t Number of days in the current month. 30
c ISO 8601 formatted date 2024-04-18T04:33:22+00:00
r RFC 5322 formatted date Thu, 18 Apr 2024 04:33:22 +0000


This parser function takes a date and/or time (in the Gregorian calendar) and formats it according to the syntax given. A date/time object can be specified; the default is the value of the magic word {{CURRENTTIMESTAMP}} – that is, the time the page was last rendered into HTML.

{{#time: format string }}
{{#time: format string | date/time object }}
{{#time: format string | date/time object | language code }}
{{#time: format string | date/time object | language code | local }}


The list of accepted formatting codes is given in the table to the right. Any character in the formatting string that is not recognized is passed through unaltered; this applies also to blank spaces (the system does not need them for interpreting the codes). There are also two ways to escape characters within the formatting string:

  1. A backslash followed by a formatting character is interpreted as a single literal character
  2. Characters enclosed in double quotes are considered literal characters, and the quotes are removed.

In addition, the digraph xx is interpreted as a single literal "x".

{{#time: Y-m-d }}2024-04-18
{{#time: [[Y]] m d }}2024 04 18
{{#time: [[Y (year)]] }}2024 (24UTCamThu, 18 Apr 2024 04:33:22 +0000)
{{#time: [[Y "(year)"]] }}2024 (year)
{{#time: i's" }}33'22"


The date/time object can be in any format accepted by PHP's strtotime() function. Both absolute (eg 20 December 2000) and relative (eg +20 hours) times are accepted.

{{#time: r|now}}Thu, 18 Apr 2024 04:33:22 +0000
{{#time: r|+2 hours}}Thu, 18 Apr 2024 06:33:22 +0000
{{#time: r|now + 2 hours}}Thu, 18 Apr 2024 06:33:22 +0000
{{#time: r|20 December 2000}}Wed, 20 Dec 2000 00:00:00 +0000
{{#time: r|December 20, 2000}}Wed, 20 Dec 2000 00:00:00 +0000
{{#time: r|2000-12-20}}Wed, 20 Dec 2000 00:00:00 +0000
{{#time: r|2000 December 20}}Fout: ongeldige tijd.


The language code in ISO 639-3 (?) allows the string to be displayed in the chosen language

{{#time:d F Y|1988-02-28|nl}}28 februari 1988
{{#time:l|now|uk}}четвер
{{#time:d xg Y|20 June 2010|pl}}20 czerwca 2010


The local parameter specifies if the date/time object refers to the local timezone or to UTC.

This is a boolean parameters: its value is determined by casting the value of the argument (see the official PHP documentation for details on how string are cast to boolean values).


<cite id="endnote_Please note that, if the variable $wgLocaltimezone is set to UTC, there is no difference in the output when local is set to true or false." style="font-style: normal;">[[#ref_Please note that, if the variable $wgLocaltimezone is set to UTC, there is no difference in the output when local is set to true or false.|^]] 


See the following examples for details:


{{#time: Y F d H:i:s|now|it|0}}2024 aprile 18 04:33:22
{{#time: Y F d H:i:s|now|it|1}}2024 aprile 18 06:33:22
{{#time: Y F d H:i:s|+2 hours||0}}2024 april 18 06:33:22
{{#time: Y F d H:i:s|+2 hours||1}}2024 april 18 08:33:22
{{#time:c|2019-05-16T17:05:43+02:00|it}}2019-05-16T15:05:43+00:00
{{#time:c|2019-05-16T17:05:43+02:00|it|0}}2019-05-16T15:05:43+00:00
{{#time:c|2019-05-16T17:05:43+02:00|it|true}}2019-05-16T17:05:43+02:00


If you've calculated a Unix timestamp, you may use it in date calculations by pre-pending an @ symbol.

{{#time: U | now }}1713414802
{{#time: r | @1713414802 }}Thu, 18 Apr 2024 04:33:22 +0000

Warning: Without the @ prefix before numeric timestamp values, the result is an error most of the time, or is an unexpected value:

{{#time: r | 1970-01-01 00:16:39 }}Thu, 01 Jan 1970 00:16:39 +0000
{{#time: U | 1970-01-01 00:16:39 }}999
{{#time: r | @999 }}Thu, 01 Jan 1970 00:16:39 +0000 (correct)
{{#time: r | 999 }}Fout: ongeldige tijd. (unsupported year format)
{{#time: r | 1970-01-01 00:16:40 }}Thu, 01 Jan 1970 00:16:40 +0000
{{#time: U | 1970-01-01 00:16:40 }}1000
{{#time: r | @1000 }}Thu, 01 Jan 1970 00:16:40 +0000 (correct)
{{#time: r | 1000 }}Fri, 18 Apr 1000 00:00:00 +0000 (interpreted as a year with current month and day of the month)
{{#time: r | 1970-01-01 02:46:39 }}Thu, 01 Jan 1970 02:46:39 +0000
{{#time: U | 1970-01-01 02:46:39 }}9999
{{#time: r | @9999 }}Thu, 01 Jan 1970 02:46:39 +0000 (correct)
{{#time: r | 9999 }}Sun, 18 Apr 9999 00:00:00 +0000 (interpreted as a year with current month and day of the month)
{{#time: r | 1970-01-01 02:46:40 }}Thu, 01 Jan 1970 02:46:40 +0000
{{#time: U | 1970-01-01 02:46:40 }}10000
{{#time: r | @10000 }}Thu, 01 Jan 1970 02:46:40 +0000 (correct)
{{#time: r | 10000 }}Fout: ongeldige tijd. (unsupported year format)

Warning: The range of acceptable input is 1 January 0111 → 31 December 9999. For the years 100 through 110 the output is inconsistent, Y and leap years are like the years 100-110, r, D, l and U are like interpreting these years as 2000-2010.
{{#time: d F Y | 29 Feb 0100 }}01 maart 0100
(correct, no leap year), but
{{#time: r | 29 Feb 0100 }}Mon, 01 Mar 0100 00:00:00 +0000 (wrong, even if 100 is interpreted as 2000, because that is a leap year)
{{#time: d F Y | 15 April 10000 }}Fout: ongeldige tijd.
{{#time: r | 10000-4-15 }}Sat, 15 Apr 2000 10:00:00 +0000


Year numbers 0-99 are interpreted as 2000-2069 and 1970-1999, except when written in 4-digit format with leading zeros:
{{#time: d F Y | 1 Jan 6 }}01 januari 2006
{{#time: d F Y | 1 Jan 06 }}01 januari 2006
{{#time: d F Y | 1 Jan 006 }}01 januari 2006
{{#time: d F Y | 1 Jan 0006 }}01 januari 0006 (4-digit format)


The weekday is supplied for the years 100-110 and from 1753, for the years 111-1752 the r-output shows "Unknown" and the l-output "<>". As a consequence, the r-output is not accepted as input for these years.}}


Full or partial absolute dates can be specified; the function will "fill in" parts of the date that are not specified using the current values:

{{#time: Y | January 1 }}2024

Warning: The fill-in feature is not consistent; some parts are filled in using the current values, others are not:
{{#time: Y m d H:i:s | June }}2024 06 18 00:00:00 Gives the start of the day, but the current day of the month and the current year. {{#time: Y m d H:i:s | 2003 }}2003 04 18 00:00:00 Gives the start of the day, but the current day of the year. }}


A four-digit number is always interpreted as a year, never as hours and minutes:

{{#time: Y m d H:i:s | 1959 }}1959 04 18 00:00:00


A six-digit number is interpreted as hours, minutes and seconds if possible, but otherwise as an error (not, for instance, a year and month):

{{#time: Y m d H:i:s | 195909 }}2024 04 18 19:59:09

Input is treated as a time rather than a year+month code.

{{#time: Y m d H:i:s | 196009 }}Fout: ongeldige tijd.

Although 19:60:09 is not a valid time, 196009 is not interpreted as September 1960.


The function performs a certain amount of date mathematics:

{{#time: d F Y | January 0 2008 }}31 december 2007
{{#time: d F | January 32 }}Fout: ongeldige tijd.
{{#time: d F | February 29 2008 }}29 februari
{{#time: d F | February 29 2007 }}01 maart
{{#time:Y-F|now -1 months}}2024-maart


The total length of the format strings of the calls of #time is limited to 6000 characters[1].

Time Zone issue[bewerken | brontekst bewerken]

There is a bug in this #time parser function (more specifically in PHP DateTime) that does not allow the passing-in of non-integers as relative time zone offsets. This issue does not apply when using an on-the-hour time zone, such as EDT. For example:

  • {{#time:g:i A | -4 hours }} ==> 12:33 AM


However, India is on a +5.5 hours time offset from UTC, and thus using its time zone will not normally allow the correct calculation of a relative time zone offset. Here's what happens:

  • {{#time:g:i A | +5.5 hours }} ==> 4:33 AM

To workaround this issue, simply convert the time into minutes or seconds, like this:

  • {{#time:g:i A | +330 minutes }} ==> 10:03 AM
  • {{#time:g:i A | +19800 seconds }} ==> 10:03 AM

#timel[bewerken | brontekst bewerken]

This function is identical to {{#time: ... }}, when the local parameter is set to true, so it always uses the local time of the wiki (as set in {{ll|Manual:$wgLocaltimezone|$wgLocaltimezone}}).

Syntax of the function is:


{{#timel: format string }}
{{#timel: format string | date/time object }}
{{#timel: format string | date/time object | language code }}

<cite id="endnote_Please note that, if the variable $wgLocaltimezone is set to UTC, there is no difference in the output when local is set to true or false" style="font-style: normal;">[[#ref_Please note that, if the variable $wgLocaltimezone is set to UTC, there is no difference in the output when local is set to true or false|^]] 

Example of the use of #time and #timel parser functions from a server where the timezone is not UTC

For instance, see the following examples:

{{#time:c|now|it}}2024-04-18T04:33:22+00:00
{{#time:c|now|it|0}}2024-04-18T04:33:22+00:00
{{#time:c|now|it|1}}2024-04-18T06:33:22+02:00
{{#timel:c|now|it}}2024-04-18T06:33:22+02:00
no-wp>https://no.wikipedia.org/wiki/Maldiskusjon:Sommertid</>

Be aware that U for both time and timel will return the same number of seconds since 1970-01-01 00:00:00 UTC on Wikipedias with different timezones than UTC (formerly known as GMT)

U Unix time. Seconds since January 1 1970 00:00:00 GMT.
Z Timezone offset in seconds.
{{#time: U}}1713414802
{{#timel: U}}1713414802
{{#time: Z}}0
{{#timel: Z}}7200
  1. ExtParserFunctions.php at phabricator.wikimedia.org