Broad Network


HTML Weeks and Durations

Microsyntax Dates and Times in HTML – Part 5

Foreword: In this part of the series I talk about weeks and durations in HTML.

By: Chrysanthus Date Published: 1 Jul 2015

Introduction

This is part 5 of my series, Microsyntax Dates and Times in HTML. In this part of the series I talk about weeks and durations in HTML. You should have read the previous parts of the series before reaching here, as this is a continuation.

Weeks
There are 7 days in a week. There are 53 weeks in a leap year and 52 weeks in an ordinary year. A particular week is a week in a particular year. The week-year is the year that has a particular week. To quote a particular week, you have to quote the week-year and then the week position in the year. The week position in the year is a number from 1 to 52 or 1 to 53.

A string is a valid week string representing a week-year and week if it consists of the following components in the given order:

Four or more digits, representing year, where year > 0; no space, a – character; no space, a W character; no space, two digits, representing the week, in the range 1 ≤ week ≤ maxweek, where maxweek is the week number of the last day of week-year (either 52 or 53).

So the microsyntax of the 23rd week of the year, 2015 is written as, 2015-W23. The microsyntax of the 6th week of the year, 2014 is 2014-W06.

Durations
Duration is the number of seconds from one point in time to another point in time. The duration from 3013-05-16 09:25:43 to 3015-11-25 17:21:54 is a number of seconds that can be calculated.

There are 60 seconds in one minute and 3600 seconds in one hour. There are 86400 seconds in one day and 604800 seconds in one week. It is not easy for people to appreciate duration in terms of seconds, especially when it is long. So, duration can also be given as a combination of weeks, days, hours, minutes and seconds.

There are two ways of quoting duration. One way to quote duration is as follows:

A string is a valid duration string representing a duration, t if it consists of the following:

A literal CAPITAL LETTER P character followed by one or more of the following subcomponents, in the order given, where the number of days, hours, minutes, and seconds corresponds to the same number of seconds as in t:

One or more digits followed by a CAPITAL LETTER D character, representing a number of days. No space!

A CAPITAL LETTER T character followed by one or more of the following subcomponents, in the order given:

-One or more digits followed by a CAPITAL LETTER H character, representing a number of hours. No space!

-One or more digits followed by a CAPITAL LETTER M character, representing a number of minutes. No space!

-The following components:

        One or more digits, representing a number of seconds.

        Optionally, a ‘.’ character followed by one, two, or three digits, representing a fraction of a second.

        A CAPITAL LETTER S character.

Examples of this type of microsyntax durations are: P258DT3H5M4S, PT3H5M4S, PT5M4S, PT4S, and P258D . This kind of duration microsyntax does not have weeks. The following kind (way) has weeks:


A string is a valid duration string representing a duration t if it consists of the following:

One or more duration time components, each with a different duration time component scale, in any order; the sum of the represented seconds being equal to the number of seconds in t.

A duration time component is a string consisting of the following components:

- Zero or more space characters.

- One or more digits, representing a number of time units, scaled by the duration time component scale specified (see below) to represent a number of seconds.

- If the duration time component scale specified is 1 (i.e. the units are seconds), then, optionally, a "." (U+002E) character followed by one, two, or three digits, representing a fraction of a second.

- Zero or more space characters.

- One of the following characters, representing the duration time component scale of the time unit used in the numeric part of the duration time component:

    CAPITAL LETTER W character
    SMALL LETTER W character
        Weeks. The scale is 604800.
    CAPITAL LETTER D character
    SMALL LETTER D character
        Days. The scale is 86400.
    CAPITAL LETTER H character
    SMALL LETTER H character
        Hours. The scale is 3600.
    CAPITAL LETTER M character
    SMALL LETTER M character
        Minutes. The scale is 60.
    CAPITAL LETTER S character
    SMALL LETTER S character
        Seconds. The scale is 1.

- Zero or more space characters.

Microsyntax examples of this second way of quoting duration are: 36W 6D 3H 5M 4S, 3H5M4S, 5M 4S, 4S, and 36W6D .

That is it for this part of the series.

Chrys

Related Links

Basics of HTML 5
Basics 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

Comments

Become the Writer's Fan
Send the Writer a Message