Understanding ISO 8601 date and time representation formats

  • Slides: 29
Download presentation
Understanding ISO 8601 date and time representation formats Texin Tex@I 18 n. Guy. com

Understanding ISO 8601 date and time representation formats Texin Tex@I 18 n. Guy. com Xen. Craft

Objectives for this session n n ISO 8601: 1988 is updated in 2000. What

Objectives for this session n n ISO 8601: 1988 is updated in 2000. What is in ISO 8601: 2000? Are there potential pitfalls in using ISO 8601, especially for internationalization? If so, are there workarounds? 21 st International Unicode Conference 2 Dublin, Ireland, May 2002

Agenda Brief Overview of ISO 8601 Problem Areas Solutions 21 st International Unicode Conference

Agenda Brief Overview of ISO 8601 Problem Areas Solutions 21 st International Unicode Conference 3 Dublin, Ireland, May 2002

ISO 8601: 2000 Overview n Dates – Calendar dates – Ordinal dates – Week

ISO 8601: 2000 Overview n Dates – Calendar dates – Ordinal dates – Week dates n Time of day – Local vs. Coordinated Universal Time (UTC) – Combined date and time n Time-intervals – Recurring time-intervals 21 st International Unicode Conference 4 Dublin, Ireland, May 2002

Representing dates, times, durations and intervals n Uses character representation – ISO/IEC 646 (ASCII),

Representing dates, times, durations and intervals n Uses character representation – ISO/IEC 646 (ASCII), no spaces n Separators (Extended Format) – Hyphens, Colons, Solidus, Number sign n Truncation – Omission of higher order components n Reduced Precision – Omission of lower order components n n Expansion- years < 0 or years > 9999 Fixed length fields using leading zeros 21 st International Unicode Conference 5 Dublin, Ireland, May 2002

Representing dates, times, durations and intervals n Designators – “P” is time-interval designator –

Representing dates, times, durations and intervals n Designators – “P” is time-interval designator – “R” is recurring time-interval designator – “T” indicates start of Time elements – “W” is week designator – “Z” is UTC designator n Duration designators – Y, M, W, D, H, M, S may be used – M can be minute, month, or both 21 st International Unicode Conference 6 Dublin, Ireland, May 2002

Calendar Dates n Gregorian calendar – 1875 is reference point – Common (365) and

Calendar Dates n Gregorian calendar – 1875 is reference point – Common (365) and Leap (366) years – Leap is every 4 th year except centennial years that are not integrally divisible by 400 – Gregorian is used even for years < 1582 (by mutual agreement). – Year 0000 is leap. 21 st International Unicode Conference 7 Dublin, Ireland, May 2002

Calendar week n n n Monday is day 1, Sunday is day 7. Weeks

Calendar week n n n Monday is day 1, Sunday is day 7. Weeks are numbered 1 - 52 or 1 - 53. Week 1 includes the first Thursday of year. – Alternatively, Week 1 includes Jan 4. n Week 1 may include 3 days of last year. – Last week may include 3 days of next year. 21 st International Unicode Conference 8 Dublin, Ireland, May 2002

Representing dates n Calendar date – year, month, day number within month n Ordinal

Representing dates n Calendar date – year, month, day number within month n Ordinal date – year, day number within year n Week date – year, week, number within week 21 st International Unicode Conference 9 Dublin, Ireland, May 2002

Representing dates 21 st International Unicode Conference 10 Dublin, Ireland, May 2002

Representing dates 21 st International Unicode Conference 10 Dublin, Ireland, May 2002

ISO 8601: 2000 Overview n Dates – Calendar dates – Ordinal dates – Week

ISO 8601: 2000 Overview n Dates – Calendar dates – Ordinal dates – Week dates n Time of day – Local vs. Universal Time Coordinated (UTC) – Combined data and time n Time-intervals – Recurring time-intervals 21 st International Unicode Conference 11 Dublin, Ireland, May 2002

Representing times n n n Hours 00 -24 (allowing midnight-midnight) Minutes 00 -59 Seconds

Representing times n n n Hours 00 -24 (allowing midnight-midnight) Minutes 00 -59 Seconds 00 -60 (allowing leap seconds) Decimal fractions of hour, minute, second Local and Universal (UTC) time 21 st International Unicode Conference 12 Dublin, Ireland, May 2002

Representing times 21 st International Unicode Conference 13 Dublin, Ireland, May 2002

Representing times 21 st International Unicode Conference 13 Dublin, Ireland, May 2002

Combined date and time “T” indicates start of time n Mix and match as

Combined date and time “T” indicates start of time n Mix and match as needed: Calendar dates + local time n YYYY-MM-DDThh: mm Ordinal dates + UTC time YYYY-DDDThh: mm. Z Week dates + offset from UTC YYYYWww. DThh: mm±hhmm 21 st International Unicode Conference 14 Dublin, Ireland, May 2002

ISO 8601: 2000 Overview n Dates – Calendar dates – Ordinal dates – Week

ISO 8601: 2000 Overview n Dates – Calendar dates – Ordinal dates – Week dates n Time of day – Local vs. Universal Time Coordinated (UTC) – Combined data and time n Time-intervals – Recurring time-intervals 21 st International Unicode Conference 15 Dublin, Ireland, May 2002

Representing time-intervals n n “P” indicates a duration (period) Intervals come in 4 varieties:

Representing time-intervals n n “P” indicates a duration (period) Intervals come in 4 varieties: – start and end times YYYY-MM-DDThh: mm: ss/YYYY-MM-DDThh: mm: ss – durations Pn. Yn. Mn. DTn. Hn. Mn. S P 2 Y 10 M 15 DT 10 H 30 M 20 S 2 Yr, 10 mon, 15 days, 10 hrs. 30 min. 20 sec. P 6 W is a duration of 6 weeks. 21 st International Unicode Conference 16 Dublin, Ireland, May 2002

Representing time-intervals n The remaining 2 varieties – start time and duration YYYY-MM-DDThh: mm:

Representing time-intervals n The remaining 2 varieties – start time and duration YYYY-MM-DDThh: mm: ss/Pn. Yn. Mn. DTn. Hn. Mn. S or YYYY-MM-DDThh: mm: ss/PYYYY-MM-DDThh: mm: ss 1985 -04 -12 T 23: 20: 50/P 0001 -02 -15 T 12: 30: 00 – duration and end time Pn. Yn. Mn. DTn. Hn. Mn. S/YYYY-MM-DDThh: mm: ss or PYYYY-MM-DDThh: mm: ss/YYYY-MM-DDThh: mm: ss 21 st International Unicode Conference 17 Dublin, Ireland, May 2002

Recurring time-intervals n Recurring time intervals are expressed by: – # of recurrences and

Recurring time-intervals n Recurring time intervals are expressed by: – # of recurrences and start and end times – # of recurrences and a duration – # of recurrences & start time & a duration – # of recurrences & duration & end time n n If # of recurrences is not provided, then the number is unbounded “R” is used to indicate recurrence 21 st International Unicode Conference 18 Dublin, Ireland, May 2002

Examples of recurring time-intervals Recurring with Start and End Times: Rn/YYYY-MM-DDThh: mm: ss R

Examples of recurring time-intervals Recurring with Start and End Times: Rn/YYYY-MM-DDThh: mm: ss R 12/1985 -04 -12 T 23: 20: 50/1985 -06 -25 T 10: 30: 00 Recurring with a duration: Rn/Pn. Yn. Mn. DTn. Hn. Mn. S R 12/P 2 Y 10 M 15 DT 10 H 20 M 20 S Recurring with a Start Time and duration: Rn/YYYY-MM-DDThh: mm: ss/Pn. Yn. Mn. DTn. Hn. Mn. S R 12/1985 -04 -12 T 23: 20: 50/P 2 Y 2 M 15 DT 12 H 30 M 0 S 21 st International Unicode Conference 19 Dublin, Ireland, May 2002

Benefits of ISO 8601 n n n Human-readable Easy to use Easy to parse,

Benefits of ISO 8601 n n n Human-readable Easy to use Easy to parse, unambiguous Easy to sort Many date-time schemes exist, a standard is needed 21 st International Unicode Conference 20 Dublin, Ireland, May 2002

Agenda Brief Overview of ISO 8601 Problem Areas Solutions 21 st International Unicode Conference

Agenda Brief Overview of ISO 8601 Problem Areas Solutions 21 st International Unicode Conference 21 Dublin, Ireland, May 2002

Ambiguities n Future leap seconds are unpredictable Is 2010 -03 -31 T 23: 59:

Ambiguities n Future leap seconds are unpredictable Is 2010 -03 -31 T 23: 59: 60 Z valid? n Year, month, minute have varying sizes P 1 M = P 28 D or P 29 D or P 30 D or P 31 D n Mismatched precision 1985 W 50 <= 1985 W 501? n n Truncation opens the door for Y 2 K issues Variations of 8601 exist in practice – Julian, Gregorian, Emperor. . . 21 st International Unicode Conference 22 Dublin, Ireland, May 2002

Ambiguities n Date arithmetic is not defined 2001 -03 -30 + P 1 M

Ambiguities n Date arithmetic is not defined 2001 -03 -30 + P 1 M = 2001 -04 -29 (Add 30 days) 2001 -03 -30 + P 1 M = 2001 -04 -30 (Add 1 mon. ) n Addition is not commutative or associative 2001 -03 -30 + P 1 D + P 1 M = 2001 -04 -30 2001 -03 -30 + P 1 M + P 1 D = 2001 -05 -01 n n Subtraction is not the inverse of Addition Precision of decimal fractions can vary 21 st International Unicode Conference 23 Dublin, Ireland, May 2002

Conversions n n Gregorian calendar adopted at different times around the world Most calendars

Conversions n n Gregorian calendar adopted at different times around the world Most calendars do not include year 0. 8601 extends leap years into the past, other calendars do not. Dates without times are often not qualified by time zone. – Time zones (currently) go from -13 to +12 – So the date could be +/- 1 day 21 st International Unicode Conference 24 Dublin, Ireland, May 2002

Conversions n n Laws determining daylight savings time change continually Difficult to know local

Conversions n n Laws determining daylight savings time change continually Difficult to know local time offsets. 21 st International Unicode Conference 25 Dublin, Ireland, May 2002

Agenda Brief Overview of ISO 8601 Problem Areas Solutions 21 st International Unicode Conference

Agenda Brief Overview of ISO 8601 Problem Areas Solutions 21 st International Unicode Conference 26 Dublin, Ireland, May 2002

Solutions n n Mutual Agreements Referencing other standards and implementations – e. g. Java

Solutions n n Mutual Agreements Referencing other standards and implementations – e. g. Java n Standards employing 8601 may need to introduce rules or constraints – e. g. XML Schema n Restrict use of 8601 formats 21 st International Unicode Conference 27 Dublin, Ireland, May 2002

Acknowledgements n Mark Davis (IBM) www. macchiato. com/unicode/time. Intervals. htm n W 3 C

Acknowledgements n Mark Davis (IBM) www. macchiato. com/unicode/time. Intervals. htm n W 3 C Internationalization working and interest groups Resources n ISO’s web page to order the standard: http: //www. iso. ch/cate/d 26780. html n Mail list: ISO 8601@yahoogroups. com n Links: groups. yahoo. com/group/ISO 8601/files/pdf_link. htm http: //aa. usno. navy. mil/faq/docs/UT. html 21 st International Unicode Conference 28 Dublin, Ireland, May 2002

Questions 21 st International Unicode Conference 29 Dublin, Ireland, May 2002

Questions 21 st International Unicode Conference 29 Dublin, Ireland, May 2002