HTML5 Time and Floating Datetimes
Microsyntax Dates and Times in HTML – Part 2
Foreword: In this part of the series, I talk about HTML time in mycrosyntax format; I also talk about floating dates and times.
By: Chrysanthus Date Published: 1 Jul 2015
Introduction
Time
In HTML, time consists of the hour, minute and second. It is possible for the second to have a fraction. For example, you can have, 27 and a ˝ seconds, written as 27.5. You can also have 28 and 2/100 seconds written as 38.02 seconds. You can also have 56 and 1/8 seconds written as 56.125 seconds. So, in HTML the microsyntax time consists of the hour, minute and second which may have a fractional part written as a decimal in 1, 2 or 3 places. Well, the second and its possible fraction are actually optional in HTML time.
If you ask somebody for the time to be read from his watch, he would give you the hour and minute. Hardly would he give you the second, not to talk of the fraction of the second. The second and its fraction is used in technical life, like in running competition and scientific work. That is why, in HTML time, the second and it possible fraction are optional.
A string is a valid time string representing an hour, a minute, and a second if it consists of the following components in the given order:
Two digits representing hour in the range 0 ≤ hour ≤ 23; no space, a : character; no space, two digits representing minute in the range 0 ≤ minute ≤ 59; no space, optionally (required if second is non-zero):
a : character; no space, two digits representing the integer part of second in the range 0 ≤ s ≤ 59; optionally (required if second is not an integer):
a FULL STOP character (.); no space, one, two, or three digits representing the fractional part of second.
For the hour, 0 is 12 O’Clock midnight and 23 is 11 pm. For all the numbers, if the number is naturally one digit, you precede the one digit with zero.
Examples of mycrosyntax times are, 09:35:41.3, 15:35:41 and 09:35 .
When an incident has occurred, people usually ask for the date (e.g. 2013-05-19) the incident occurred. Occasionally, people would want to know the date as well as the time when the incident occurred; like in crime investigation. In this case, you need a combined date and time figure; that is, a figure that consists of the date as well as the time when the incident occurred.
A floating date and time consists of a specific date, consisting of a year, a month, and a day of the month, and then a time, consisting of an hour, a minute, a second, and a fraction of a second.
A string is a valid floating date and time string representing a date and time if it consists of the following components in the given order:
A valid date string representing the date; no space, a T character or a single SPACE character; no space, a valid time string representing the time.
Examples of microsyntax valid floating date and time (datetime) are, 2016-12-03T09:35:41.003 and 2016-12-03 09:35:41.003 .
Note that the T is in uppercase and not lowercase.
Note that the floating date and time has second and fraction of a second, which are obligatory, but you will not need in many occasions. Well, the guys of HTML5 were smart. They have given us the possibility to have a microsyntax floating datetime that would omit the second and its fraction. They call the syntax, “valid normalized floating date and time”.
A string is a valid normalized floating date and time string representing a date and time if it consists of the following components in the given order:
A valid date string representing the date; no space, a T character; a valid time string representing the time, expressed as the shortest possible string for the given time (e.g. omitting the seconds component entirely if the given time is zero seconds past the minute).
An example of a microsyntax normalized floating datetime is, 2016-12-03T09:35 .You are likely to be using the normalized floating datetime than the non-normalized floating datetime. Note that here, the single space in place of the T character is not allowed.
HTML5 can be easy going, so the following are still valid normalized floating datetimes: 2016-12-03T09:35:41 and 2016-12-03T09:35:41.003.
As you can see, a complete normalized floating datetime is still a non-normalized floating datetime. To distinguish between the two, always use the T instead of the single space, for the normalized floating datetime.
The differences between the microsyntax normalized floating datetime and the microsyntax non-normaliized floating datetime are, that in the normalized floating datetime, the time can be short, and the normalized floating datetime always has the T and never the single space.
That is it for this part of the series. We stop here and continue in the next part.
Chrys
Related Links
Basics of HTML 5Basics of ECMAScript
HTML DOM Basics
CSS Basics
Text Elements in HTML
Grouping Content
Microsyntax Dates and Times in HTML
Sectioning Content
Common Idioms without Dedicated Elements
HTML Embedded Content
HTML Insecurities and Prevention
Presentation Mathematical Markup Language
More Related Links
PurePerl MySQL API
Major in Website Design
Perl Course - Optimized
Web Development Course
BACK NEXT