Re: FAQ Topic - How do I format a date with javascript? (2009-06-01)



Dr J R Stockton wrote:
In comp.lang.javascript message <h1a7fu$2cd$1@xxxxxxxxxxxxx
september.org>, Wed, 17 Jun 2009 00:54:36, Garrett Smith
<dhtmlkitchen@xxxxxxxxx> posted:

In my own casual research, I asked some friends/acquaintances of mine
who speak very little English to participate.

They'll understand such dates. Try asking Americans, who know very
little international.


When asked, each responded negatively; neither had seen that format. I asked the second interviewee how he knew what "T" meant. He told me that he assumed that "T" meant "Time". I concluded that he solved this by intuition, and that the format, including "T", was intuitive to him.

Regarding the "ask Americans", I have, I may have mentioned in this or another thread, that I have used the Extended YYYY-MM-DD format at the doctors office forms where __/__/__ was provided on the form. I simply struck a line thorugh that and wrote an ISO Extended YYYY-MM-DD above it. Though I did not confirm, they did not ask for any clarification. If clarification was needed, they had about a 30 minute window to ask.


ISO 8601 does not allow replacing T with whitespace. Section 3.4.1:
| Unless explicitly allowed by this International Standard the character
| “space” shall not be used in the representations

Read on to 4.3.2, containing


Right, and "omitted" does not mean "replaced with something else."

NOTE By mutual agreement of the partners in information interchange,
the character [T] may be omitted in applications where there is no
risk of confusing a date and time of day representation with others
defined in this International Standard.

Disregard SQL and others; they have their own standards which may be
ISO-like and clearly need to be complied with. Consider date/times for
use within the current script and for interaction with the user.


The FAQ code itself is useful for derivative standard formats.

As you have seen in the jscript newsgroup, there are cases where evidence of the existence such standards would be relavant. The poster in that thread wrote:

| I have to write my software to work in the world as it exists today.

Mentioning other formats recitifies the misconception that ISO 8601 is a "Europeoan format". RFC 3339 says its a practical standard that is used on the web, for humans. ISO 9075 says its used in SQL.

A sentence and a link mentioning derivative standards should make that obvious.

* One can use the "T" format, which is not quite as easy to read because
of the lack of whitespace between the two parts.

* One can omit the "T", which is silly in Extended.

* One can replace the "T" with a space, taking the normal web-author
argument of power as equivalent to the agreement required by ISO (it's
much the same as using author-preferred border and font-family in the
FAQ).


No, it is not the same. That date format is defined by ISO 8601. The border of the root element is styling.

When this entry reaches a reasonable stopping point, I'll upload the new version. No border on the root.

* One can decide not to write the (date-and-time) in ISO, but to write
the date in ISO, followed by a space, followed by the time in ISO.


Right. However, the statement "The T can be replaced with whitespace", in the given context seems misleading. It could mislead the reader to believing that that is a given allowance by ISO 8601. In fact, ISO 8601 does not allow replacing T with whitespace.

If there is some reason to require the date-and-time to be a single
lexical unit, use the "T". Otherwise, choose either the third or the
fourth above.




Main entry for Dates:

| ISO 8601 defines date and time formats. Some benefits include:
| * language-independent and unambiguous world-wide.
| * sortable with a trivial string comparison.
by xxxxxxxxxxx
| * easily readable and writable by software.
| * The basis for other standards, such as ISO 9075 and rfc 3339.

Fix capitalisation and punctuation, and it will do. But it is not
euphonious; the last line jars. "The basis" should be more adjectival.


Remove the full-stop on the list items. Those aren't sentences.

"The basis for" could be changed to:

"compatible with"

| * compatible with standards ISO 9075 and rfc 3339

Does that need qualifying? I want to avoid sounding as if ISO 8601 format came after those.


| The ISO Extended format for common date is YYYY-MM-DD, and for time is
^ full ^ local
| hh:mm:ss.
There "full" is a nod to not requiring :ss ; without an offset, the date
is local without indicating where.


| For a local date/time offset from UTC, use YYYY-MM-DDThh:mm:ss±hh:mm.
xxxxxx ^ with an
There, a location may be implied, but the overall value is UTC.


"local event" seems more to the point.

Compare:
| For a date/time with an offset from UTC, use
| YYYY-MM-DDThh:mm:ss±hh:mm.

-or-

| For a local event with an offset from UTC, use
| YYYY-MM-DDThh:mm:ss±hh:mm.


[...]

Revised Draft:
| ISO 8601 defines date and time formats. Some benefits include:
| * language-independent and unambiguous world-wide
| * sortable with a trivial string comparison
| * easily readable and writable by software
| * compatible with standards ISO 9075 and rfc 3339
|
| The ISO Extended format for common date is YYYY-MM-DD, and for time is
| hh:mm:ss.
|
| For a local event with an offset from UTC, use
| YYYY-MM-DDThh:mm:ss±hh:mm.
|
| The T can be omitted where that would not cause ambiguity. For
| rfc 3339 compliance, it may be replaced by a space and for SQL,
| it *must* be replaced by a single space.

Well?


NB. Does not mention about writing dates with words. Should have at
least a mention. For example:-

| For formatting dates to words, see: _url_.

Or "numeric" in the heading. No need to discuss it here, because after
reading the numeric section, adding day-of-week or using month-as-word
should be obvious.


Not necessarily. That day and month names need l10n, and so does the order and symbols associated therewith. This requires server processing. Such discussion ought to mention cldr.

That is, provided that an example of declaring an array literal is added
to the FAQ (it could be a new section; it's been answered, if not asked,
often enough), for which month serves as an example. Could use day-of-
week 0 to 7 ["Sun", "Mon" ..."Sat", Sun"] to accommodate both JS/C and
ISO numbering. Ought to include an example "[, a, ... , z]" for when an
array 1 to N is needed.


A section on Arrays would be valuable to the FAQ.

The size of the FAQ may seem intimidating. To mitigate that, its document presentation can be improved.

Garrett
--
The official comp.lang.javascript FAQ:
http://jibbering.com/faq/
.



Relevant Pages

  • Re: VISTA
    ... One of the most powerful aspects of open source software is that you cannot make a change like the one you are suggesting - if Sun tried to change to a new closed format, the project would be quickly forked and backing companies, developers, and users would switch to the fork. ... A slightly incompatible version of this format was fast-tracked by ECMA through ISO. ... Although Open Office now supports importing these files, the standard format for Open Office is still the single *real* standard format, namely Open Document Format. ... OASIS is an independent standards group with a solid reputation, thus keeping ODF separate from any one implementation and ensuring it can be freely used by anyone. ...
    (comp.arch.embedded)
  • Re: DVD Burning Software
    ... thought the built-in CD writing in XP wrote in ISO 9660 format both ... There is ISO 9660 and there are various extensions to that specification. ... The Windows XP CD writing utility writes in Mode 1 + Orange Book. ... The act of closing the disc writes the final table of contents to the ...
    (microsoft.public.windowsxp.hardware)
  • Re: Burn from VOB files?
    ... in article <Re: Burn from VOB files?>, ... Is it normal that in some circumstances a DVD could not be opened ... Extracts\Countdown ISO structure\VIDEO_TS\VTS_01_1.VOB ... Format: MPEG Video ...
    (rec.video.desktop)
  • Re: FAQ Topic - What does the future hold for ECMAScript? (2009-04-12)
    ... Looking at the ISO8601 format they've used, ... ISO 8601, interpreted, likes the comma, sneers at the full stop, but has ... ECMA provide that method with only JSON support in mind. ...
    (comp.lang.javascript)
  • Re: FAQ Topic - How do I format a date with javascript? (2009-06-01)
    ... instead of a YYYY-MM-DD string also works; ... The ISO 8601 Extended format can be understood internationally, ... ISO 8601 Extended formats can be... ... Most inputs will pass validation, so the need is to reach success ...
    (comp.lang.javascript)