From: nick on
On Apr 22, 9:56 am, Dr J R Stockton <reply1...(a)merlyn.demon.co.uk>
wrote:
> [nick:]
> >ISO-8601 (example: 2005-08-15T15:52:01+0000)
> >const string DateTime::ISO8601 = Y-m-d\TH:i:sO ;
> >O  Difference to Greenwich time (GMT) in hours  Example: +0200
>
> That should really be to UTC.  And it is not in hours - 200 hours is
> 8 1/3 rimes round the world - but in hours & minutes.

Good catch on the hours. Why the distinction between GMT and UTC?

> > What do you guys think?
>
> On such a matter, one should not think.  Instead, one should read the
> current version of ISO 8601.

In fairness, reading that document from front to back (I just did)
does require one to think, or at least to concentrate. Check out this
monstrosity of a sentence:

| By mutual agreement of the partners in information interchange,
| duration may be expressed in conformity with the format used
| for time-points, as specified in 5.2.1, 5.2.2, 5.2.3, 5.3.1.5
| and 5.4, where the formats of 5.4 are restricted for the date
| component to the formats in 5.2.1 and for the time-of-the-day
| component to the formats in 5.3.1.1 through 5.3.1.3.

Even if I had already read this I think I would have liked to get a
second opinion.

> ISO 8601:2004(E) Section 4.2.5.1 "Difference between local time and UTC
> of day" does include
>         Basic format:           ±hhmm   Example: +0100
>         Extended format:        ±hh:mm  Example: +01:00
> so the offset can indeed be expressed in either manner.

Agreed.

> *B*U*T* ISO 8601:2004(E) Section 4.2.5.2 "Local time and the difference
> from UTC" includes
>         Basic format:           hhmmss±hhmm     Example: 152746+0100
>         Extended format:        hh:mm:ss±hh:mm  Example: 15:27:46+01:00

> Clearly "basic" and "extended" each cover the whole lot, and are not to
> be mixed.  Sowww.php.netis wrong.

I also get the impression that they weren't supposed to be mixed. SS
5.4.2 (d) of that document says:

| [T]he expression shall either be completely in basic format,
| in which case the minimum number of separators necessary
| for the required expression is used, or completely in
| extended format, in which case additional separators shall
| be used in accordance with 5.2 and 5.3.

The title of 5.4.2 is "Representations other than complete." What do
you suppose that means?

> You should provide a version which is correct, and if necessary an
> alternative compatible withwww.php.net.

Ok, but with different names from the PHP constant.. maybe ISO8601_E
and ISO8601_B. ISO8601 keeps the PHP behavior.

> My DATE2 provides, AFAIR, all reasonable formats and useful
> combinations.

Cool, so you should be able to tell me if I've done a good job when I
finish mine ;)

> Please use a fuller name and a distinctive signature - you should not
> assume that you are the only possible nick.

I'll think about it...

-- Nick___
From: nick on
On Apr 23, 9:19 am, Stefan Weiss <krewech...(a)gmail.com> wrote:
> I think if your goal is to clone something, your output should match the
> original's, warts and all.

I think so too. I'm keeping to the original behavior as much possible
and adding a few new things for strict standards compliance.

> By the way, there's a project which is trying to port all PHP functions
> to JS, for some reason. I didn't look at their code, but you may get
> some inspirations from their implementation of the date() function:
>
> http://phpjs.org/functions/index

I've seen it, it looks interesting. Part of the reason I'm doing this
is to sharpen my javascript skills, so I don't want to borrow too much
from other sources before I try to do it myself... I'd rather try it
first and then see how my approach compares to what others have done.
My date thing is basically done as far as actually formatting the
dates, I'm just going through and cleaning things up at this point.

-- Nick
From: Dr J R Stockton on
In comp.lang.javascript message <fadf01fc-121f-470a-818a-f2ef42c69935(a)8g
2000yqz.googlegroups.com>, Tue, 20 Apr 2010 21:28:30, nick
<nick___(a)fastmail.fm> posted:

>After reading this:
>
>http://www.w3.org/TR/NOTE-datetime
>
> "TZD = time zone designator (Z or +hh:mm or -hh:mm)"
> "1994-11-05T08:15:30-05:00"
>
>I'd say that ISO 8601 formatted dates should have a colon between the
>hours and minutes in the time zone designator, right?

Partly so. That form is correct, though TZD designates the Offset and
not the Zone. Read on.

>It looks like PHP got this wrong:
>
>http://www.php.net/manual/en/class.datetime.php
>
>ISO-8601 (example: 2005-08-15T15:52:01+0000)
>const string DateTime::ISO8601 = Y-m-d\TH:i:sO ;
>O Difference to Greenwich time (GMT) in hours Example: +0200

That should really be to UTC. And it is not in hours - 200 hours is
8 1/3 rimes round the world - but in hours & minutes.


>What's going on here? Did PHP get this wrong? If so, I wonder how I
>should proceed with a PHP date formatting clone in javascript... keep
>the incorrect behavior from PHP, or follow the standard? What do you
>guys think?

On such a matter, one should not think. Instead, one should read the
current version of ISO 8601.

ISO 8601:2004(E) Section 4.2.5.1 "Difference between local time and UTC
of day" does include
Basic format: �hhmm Example: +0100
Extended format: �hh:mm Example: +01:00
so the offset can indeed be expressed in either manner.

*B*U*T* ISO 8601:2004(E) Section 4.2.5.2 "Local time and the difference
from UTC" includes
Basic format: hhmmss�hhmm Example: 152746+0100
Extended format: hh:mm:ss�hh:mm Example: 15:27:46+01:00

Clearly "basic" and "extended" each cover the whole lot, and are not to
be mixed. So www.php.net is wrong.

You should provide a version which is correct, and if necessary an
alternative compatible with www.php.net.

My DATE2 provides, AFAIR, all reasonable formats and useful
combinations.



Please use a fuller name and a distinctive signature - you should not
assume that you are the only possible nick.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
From: Stefan Weiss on
On 21/04/10 06:28, nick wrote:
> What's going on here? Did PHP get this wrong? If so, I wonder how I
> should proceed with a PHP date formatting clone in javascript... keep
> the incorrect behavior from PHP, or follow the standard?

I think if your goal is to clone something, your output should match the
original's, warts and all.

By the way, there's a project which is trying to port all PHP functions
to JS, for some reason. I didn't look at their code, but you may get
some inspirations from their implementation of the date() function:

http://phpjs.org/functions/index


--
stefan