|
View:
New views
19 Messages
—
Rating Filter:
Alert me
|
|
|
DOMTimeStamp interface not defined in L3 events...Since the DOMTimeStamp is not defined in the L3 Events spec,
I was wondering how it should be implemented in JavaScript? All browsers that
support the property seem to support it as a JavaScript Number object. Shouldn’t
it be a JavaScript Date object? |
|
|
Re: DOMTimeStamp interface not defined in L3 events...Hi, Travis-
Travis Leithead wrote (on 9/30/09 1:01 PM): > Since the DOMTimeStamp is not defined in the L3 Events spec, I was > wondering how it should be implemented in JavaScript? All browsers that > support the property seem to support it as a JavaScript Number object. > Shouldn’t it be a JavaScript Date object? It's defined in DOM3 Core as an "unsigned long long" [1]. This should probably be revised in DOM Core.next. Doesn't HTML5 say something about this, as well? [1] http://www.w3.org/TR/DOM-Level-3-Core/core.html#Core-DOMTimeStamp Regards- -Doug Schepers W3C Team Contact, SVG and WebApps WGs |
|
|
|
|
|
Re: DOMTimeStamp interface not defined in L3 events...On Wed, 30 Sep 2009 22:11:09 +0200, Doug Schepers <schepers@...> wrote:
> This should probably be revised in DOM Core.next. Doesn't HTML5 say > something about this, as well? No, HTML5 does propose that some attributes return a Date object instead, which is intended to be the ECMAScript Data object though WebIDL still needs to make that explicit. -- Anne van Kesteren http://annevankesteren.nl/ |
|
|
Re: DOMTimeStamp interface not defined in L3 events...On Wed, 30 Sep 2009 22:01:19 +0200, Travis Leithead <travil@...>
wrote: > Since the DOMTimeStamp is not defined in the L3 Events spec, I was > wondering how it should be implemented in JavaScript? All browsers that > support the property seem to support it as a JavaScript Number object. > Shouldn't it be a JavaScript Date object? I believe last time we looked into this it was figured out we could not change it to a Date object. I wish we could, but there is probably too much content out there using it in this way already. -- Anne van Kesteren http://annevankesteren.nl/ |
|
|
|
|
|
Re: DOMTimeStamp interface not defined in L3 events...On Sat, 3 Oct 2009, Jacob Rossi wrote:
> Annevk wrote: > > I believe last time we looked into this it was figured out we could not > > change it to a Date object. I wish we could, but there is probably too > > much content out there using it in this way already. > > It probably does have to stay the say it is for backwards > compatibility. But it sure would be nice to be able to do something > like: > > var jsdate = e.timeStamp.toDate(); Can't you do var jsdate = new Date(e.timeStamp); ...? (Might need a factor of 1000 multiplier.) -- Ian Hickson U+1047E )\._.,--....,'``. fL http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.' |
|
|
Re: DOMTimeStamp interface not defined in L3 events...> Can't you do
> > var jsdate = new Date(e.timeStamp); > > ...? (Might need a factor of 1000 multiplier.) Doesn't work for me. Test page: http://www.jacobrossi.com/eventdates.html In Firefox, The value of e.timeStamp *looks* like a UNIX timestamp (milliseconds since Jan. 1, 1970 midnight), which is what MDC documentation led me to believe it should be. However, it's not a correct timestamp and is not off by a simple factor of 1000 or something. Further, trying to convert an example of a HTML5 "valid date and time string" using the date.parse does not work. In Chrome, The value of e.timeStamp is a date object. Also, the date.parse() method is unable to convert the example date and time string from HTML5. I think using a JS date object makes the most sense (especially since it's easy to go from a date object to either a date/time string OR unix timestamp). But if there are sites that expect this to be unix timestamp or date string, then this would break them. --Jacob On Sat, Oct 3, 2009 at 10:03 PM, Ian Hickson <ian@...> wrote: > On Sat, 3 Oct 2009, Jacob Rossi wrote: >> Annevk wrote: >> > I believe last time we looked into this it was figured out we could not >> > change it to a Date object. I wish we could, but there is probably too >> > much content out there using it in this way already. >> >> It probably does have to stay the say it is for backwards >> compatibility. But it sure would be nice to be able to do something >> like: >> >> var jsdate = e.timeStamp.toDate(); > > Can't you do > > var jsdate = new Date(e.timeStamp); > > ...? (Might need a factor of 1000 multiplier.) > > -- > Ian Hickson U+1047E )\._.,--....,'``. fL > http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. > Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.' > |
|
|
Re: DOMTimeStamp interface not defined in L3 events...Jacob Rossi wrote:
> Doesn't work for me. Test page: http://www.jacobrossi.com/eventdates.html > > In Firefox, Oh, boy. There are at least two separate things going on here: 1) Gecko is not internally consistent. Sometimes its event timestamps are microseconds since the UNIX epoch (or at least sort of; this uses the computer's internal clock), sometimes they're ticks since some arbitrary (but consistent for a browser run, more or less) point in time. The tick interval is a millisecond in some cases but not others; it's OS-dependent (and never smaller than 10 microseconds or larger than 1 millisecond). A complete mess, all in all. 2) The actual treatment of event.timestamp is DOM2 Events is pretty underdefined (though not to the point of allowing all of the above mess). It specifies that the timestamp is "milleseconds relative to the epoch" but then clearly goes on to say: "Examples of epoch time are the time of the system start or 0:0:0 UTC 1st January 1970." Presumably the latter part is fixable as part of a spec (define the epoch to be the UNIX epoch). The former part just needs to be fixed in Gecko. See https://bugzilla.mozilla.org/show_bug.cgi?id=77992 and https://bugzilla.mozilla.org/show_bug.cgi?id=323039 for the relevant bugs. > The value of e.timeStamp *looks* like a UNIX timestamp (milliseconds > since Jan. 1, 1970 midnight), which is what MDC documentation led me > to believe it should be. The MDC documentation has a certain tencency to be based on the DOM specs. :( > I think using a JS date object makes the most sense (especially since > it's easy to go from a date object to either a date/time string OR > unix timestamp). But if there are sites that expect this to be unix > timestamp or date string, then this would break them. I would be very surprised if such sites exist, honestly, given the above situation with Gecko. -Boris |
|
|
Re: DOMTimeStamp interface not defined in L3 events...On 10/4/09 10:28 PM, Jacob Rossi wrote:
>> Can't you do >> >> var jsdate = new Date(e.timeStamp); >> >> ...? (Might need a factor of 1000 multiplier.) > > Doesn't work for me. Test page: http://www.jacobrossi.com/eventdates.html > > In Firefox, > The value of e.timeStamp *looks* like a UNIX timestamp (milliseconds > since Jan. 1, 1970 midnight), which is what MDC documentation led me > to believe it should be. However, it's not a correct timestamp and is > not off by a simple factor of 1000 or something. this working according to the D3E draft - return value in milliseconds. Further, trying to > convert an example of a HTML5 "valid date and time string" using the > date.parse does not work. > > In Chrome, > The value of e.timeStamp is a date object. Um. Also, the date.parse() > method is unable to convert the example date and time string from > HTML5. > > > I think using a JS date object makes the most sense (especially since > it's easy to go from a date object to either a date/time string OR > unix timestamp). But if there are sites that expect this to be unix > timestamp or date string, then this would break them. Well, it is easy to get JS Date object from milliseconds too. -Olli > > --Jacob > > > > On Sat, Oct 3, 2009 at 10:03 PM, Ian Hickson<ian@...> wrote: >> On Sat, 3 Oct 2009, Jacob Rossi wrote: >>> Annevk wrote: >>>> I believe last time we looked into this it was figured out we could not >>>> change it to a Date object. I wish we could, but there is probably too >>>> much content out there using it in this way already. >>> >>> It probably does have to stay the say it is for backwards >>> compatibility. But it sure would be nice to be able to do something >>> like: >>> >>> var jsdate = e.timeStamp.toDate(); >> >> Can't you do >> >> var jsdate = new Date(e.timeStamp); >> >> ...? (Might need a factor of 1000 multiplier.) >> >> -- >> Ian Hickson U+1047E )\._.,--....,'``. fL >> http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. >> Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.' >> > > |
|
|
Re: DOMTimeStamp interface not defined in L3 events...On Sun, 4 Oct 2009, Jacob Rossi wrote:
> > > > Can't you do > > > > var jsdate = new Date(e.timeStamp); > > > > ...? (Might need a factor of 1000 multiplier.) > > Doesn't work for me. Test page: http://www.jacobrossi.com/eventdates.html > > In Firefox, > The value of e.timeStamp *looks* like a UNIX timestamp (milliseconds > since Jan. 1, 1970 midnight), which is what MDC documentation led me > to believe it should be. However, it's not a correct timestamp and is > not off by a simple factor of 1000 or something. Further, trying to > convert an example of a HTML5 "valid date and time string" using the > date.parse does not work. Ah, in Firefox, at least on Mac, it's the number of milliseconds since the computer was last restarted. The above works in Safari. > I think using a JS date object makes the most sense (especially since > it's easy to go from a date object to either a date/time string OR unix > timestamp). But if there are sites that expect this to be unix timestamp > or date string, then this would break them. Well it depends what the use case is. If the use case is just to be able to tell the relative time between events, Firefox's behaviour is fine. Why do you want Date objects? -- Ian Hickson U+1047E )\._.,--....,'``. fL http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.' |
|
|
Re: DOMTimeStamp interface not defined in L3 events...Either a date object or milliseconds since the epoch is fine since the
date() function makes it easy to move between formats. I just wouldn't like it being a date/time string. But if it's going to be milliseconds, it should be since the epoch---not since last restart (particularly if you want to send that timestamp back to the server). --Jacob On Sun, Oct 4, 2009 at 5:53 PM, Ian Hickson <ian@...> wrote: > On Sun, 4 Oct 2009, Jacob Rossi wrote: >> > >> > Can't you do >> > >> > var jsdate = new Date(e.timeStamp); >> > >> > ...? (Might need a factor of 1000 multiplier.) >> >> Doesn't work for me. Test page: http://www.jacobrossi.com/eventdates.html >> >> In Firefox, >> The value of e.timeStamp *looks* like a UNIX timestamp (milliseconds >> since Jan. 1, 1970 midnight), which is what MDC documentation led me >> to believe it should be. However, it's not a correct timestamp and is >> not off by a simple factor of 1000 or something. Further, trying to >> convert an example of a HTML5 "valid date and time string" using the >> date.parse does not work. > > Ah, in Firefox, at least on Mac, it's the number of milliseconds since the > computer was last restarted. > > The above works in Safari. > > >> I think using a JS date object makes the most sense (especially since >> it's easy to go from a date object to either a date/time string OR unix >> timestamp). But if there are sites that expect this to be unix timestamp >> or date string, then this would break them. > > Well it depends what the use case is. If the use case is just to be able > to tell the relative time between events, Firefox's behaviour is fine. Why > do you want Date objects? > > -- > Ian Hickson U+1047E )\._.,--....,'``. fL > http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. > Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.' > |
|
|
Re: DOMTimeStamp interface not defined in L3 events...On Sun, Oct 4, 2009 at 1:20 PM, Boris Zbarsky <bzbarsky@...> wrote:
> Jacob Rossi wrote: >> >> Doesn't work for me. Test page: >> http://www.jacobrossi.com/eventdates.html >> >> In Firefox, > > Oh, boy. There are at least two separate things going on here: > > 1) Gecko is not internally consistent. Sometimes its event timestamps are > microseconds since the UNIX epoch (or at least sort of; this uses the > computer's internal clock), sometimes they're ticks since some arbitrary > (but consistent for a browser run, more or less) point in time. The tick > interval is a millisecond in some cases but not others; it's OS-dependent > (and never smaller than 10 microseconds or larger than 1 millisecond). A > complete mess, all in all. > > 2) The actual treatment of event.timestamp is DOM2 Events is pretty > underdefined (though not to the point of allowing all of the above mess). > It specifies that the timestamp is "milleseconds relative to the epoch" but > then clearly goes on to say: "Examples of epoch time are the time of the > system start or 0:0:0 UTC 1st January 1970." > > Presumably the latter part is fixable as part of a spec (define the epoch to > be the UNIX epoch). The former part just needs to be fixed in Gecko. See > https://bugzilla.mozilla.org/show_bug.cgi?id=77992 and > https://bugzilla.mozilla.org/show_bug.cgi?id=323039 for the relevant bugs. > >> The value of e.timeStamp *looks* like a UNIX timestamp (milliseconds >> since Jan. 1, 1970 midnight), which is what MDC documentation led me >> to believe it should be. > > The MDC documentation has a certain tencency to be based on the DOM specs. > :( > >> I think using a JS date object makes the most sense (especially since >> it's easy to go from a date object to either a date/time string OR >> unix timestamp). But if there are sites that expect this to be unix >> timestamp or date string, then this would break them. > > I would be very surprised if such sites exist, honestly, given the above > situation with Gecko. What is the use case for this feature? It doesn't seem very hard to implement, but there's certainly a performance cost to getting the current time for each event. / Jonas |
|
|
Re: DOMTimeStamp interface not defined in L3 events...On 10/5/09 10:06 AM, Jonas Sicking wrote:
> On Sun, Oct 4, 2009 at 1:20 PM, Boris Zbarsky<bzbarsky@...> wrote: >> Jacob Rossi wrote: >>> >>> Doesn't work for me. Test page: >>> http://www.jacobrossi.com/eventdates.html >>> >>> In Firefox, >> >> Oh, boy. There are at least two separate things going on here: >> >> 1) Gecko is not internally consistent. Sometimes its event timestamps are >> microseconds since the UNIX epoch (or at least sort of; this uses the >> computer's internal clock), sometimes they're ticks since some arbitrary >> (but consistent for a browser run, more or less) point in time. The tick >> interval is a millisecond in some cases but not others; it's OS-dependent >> (and never smaller than 10 microseconds or larger than 1 millisecond). A >> complete mess, all in all. >> >> 2) The actual treatment of event.timestamp is DOM2 Events is pretty >> underdefined (though not to the point of allowing all of the above mess). >> It specifies that the timestamp is "milleseconds relative to the epoch" but >> then clearly goes on to say: "Examples of epoch time are the time of the >> system start or 0:0:0 UTC 1st January 1970." >> >> Presumably the latter part is fixable as part of a spec (define the epoch to >> be the UNIX epoch). The former part just needs to be fixed in Gecko. See >> https://bugzilla.mozilla.org/show_bug.cgi?id=77992 and >> https://bugzilla.mozilla.org/show_bug.cgi?id=323039 for the relevant bugs. >> >>> The value of e.timeStamp *looks* like a UNIX timestamp (milliseconds >>> since Jan. 1, 1970 midnight), which is what MDC documentation led me >>> to believe it should be. >> >> The MDC documentation has a certain tencency to be based on the DOM specs. >> :( >> >>> I think using a JS date object makes the most sense (especially since >>> it's easy to go from a date object to either a date/time string OR >>> unix timestamp). But if there are sites that expect this to be unix >>> timestamp or date string, then this would break them. >> >> I would be very surprised if such sites exist, honestly, given the above >> situation with Gecko. > > What is the use case for this feature? > > It doesn't seem very hard to implement, but there's certainly a > performance cost to getting the current time for each event. It is always possible to implement the feature by returning 0. Both D2E and D3E allow that. Olli |
|
|
Re: DOMTimeStamp interface not defined in L3 events...On Mon, Oct 5, 2009 at 2:10 AM, Olli Pettay <Olli.Pettay@...> wrote:
> On 10/5/09 10:06 AM, Jonas Sicking wrote: >> >> On Sun, Oct 4, 2009 at 1:20 PM, Boris Zbarsky<bzbarsky@...> wrote: >>> >>> Jacob Rossi wrote: >>>> >>>> Doesn't work for me. Test page: >>>> http://www.jacobrossi.com/eventdates.html >>>> >>>> In Firefox, >>> >>> Oh, boy. There are at least two separate things going on here: >>> >>> 1) Gecko is not internally consistent. Sometimes its event timestamps >>> are >>> microseconds since the UNIX epoch (or at least sort of; this uses the >>> computer's internal clock), sometimes they're ticks since some arbitrary >>> (but consistent for a browser run, more or less) point in time. The tick >>> interval is a millisecond in some cases but not others; it's OS-dependent >>> (and never smaller than 10 microseconds or larger than 1 millisecond). A >>> complete mess, all in all. >>> >>> 2) The actual treatment of event.timestamp is DOM2 Events is pretty >>> underdefined (though not to the point of allowing all of the above mess). >>> It specifies that the timestamp is "milleseconds relative to the epoch" >>> but >>> then clearly goes on to say: "Examples of epoch time are the time of the >>> system start or 0:0:0 UTC 1st January 1970." >>> >>> Presumably the latter part is fixable as part of a spec (define the epoch >>> to >>> be the UNIX epoch). The former part just needs to be fixed in Gecko. >>> See >>> https://bugzilla.mozilla.org/show_bug.cgi?id=77992 and >>> https://bugzilla.mozilla.org/show_bug.cgi?id=323039 for the relevant >>> bugs. >>> >>>> The value of e.timeStamp *looks* like a UNIX timestamp (milliseconds >>>> since Jan. 1, 1970 midnight), which is what MDC documentation led me >>>> to believe it should be. >>> >>> The MDC documentation has a certain tencency to be based on the DOM >>> specs. >>> :( >>> >>>> I think using a JS date object makes the most sense (especially since >>>> it's easy to go from a date object to either a date/time string OR >>>> unix timestamp). But if there are sites that expect this to be unix >>>> timestamp or date string, then this would break them. >>> >>> I would be very surprised if such sites exist, honestly, given the above >>> situation with Gecko. >> >> What is the use case for this feature? > > This is indeed a good question > >> >> It doesn't seem very hard to implement, but there's certainly a >> performance cost to getting the current time for each event. > > It is always possible to implement the feature by returning 0. > Both D2E and D3E allow that. That seems very strange to me. Optional features don't really have a good track record. Is there a reason to believe that sites won't depend on this feature if it's available in one or two popular browsers? Unless the feature is so useless that no-one will use it, but in that case it seems better to just remove it. / Jonas |
|
|
Re: DOMTimeStamp interface not defined in L3 events...On 10/5/09 9:07 PM, Jonas Sicking wrote:
> On Mon, Oct 5, 2009 at 2:10 AM, Olli Pettay<Olli.Pettay@...> wrote: >> On 10/5/09 10:06 AM, Jonas Sicking wrote: >>> >>> On Sun, Oct 4, 2009 at 1:20 PM, Boris Zbarsky<bzbarsky@...> wrote: >>>> >>>> Jacob Rossi wrote: >>>>> >>>>> Doesn't work for me. Test page: >>>>> http://www.jacobrossi.com/eventdates.html >>>>> >>>>> In Firefox, >>>> >>>> Oh, boy. There are at least two separate things going on here: >>>> >>>> 1) Gecko is not internally consistent. Sometimes its event timestamps >>>> are >>>> microseconds since the UNIX epoch (or at least sort of; this uses the >>>> computer's internal clock), sometimes they're ticks since some arbitrary >>>> (but consistent for a browser run, more or less) point in time. The tick >>>> interval is a millisecond in some cases but not others; it's OS-dependent >>>> (and never smaller than 10 microseconds or larger than 1 millisecond). A >>>> complete mess, all in all. >>>> >>>> 2) The actual treatment of event.timestamp is DOM2 Events is pretty >>>> underdefined (though not to the point of allowing all of the above mess). >>>> It specifies that the timestamp is "milleseconds relative to the epoch" >>>> but >>>> then clearly goes on to say: "Examples of epoch time are the time of the >>>> system start or 0:0:0 UTC 1st January 1970." >>>> >>>> Presumably the latter part is fixable as part of a spec (define the epoch >>>> to >>>> be the UNIX epoch). The former part just needs to be fixed in Gecko. >>>> See >>>> https://bugzilla.mozilla.org/show_bug.cgi?id=77992 and >>>> https://bugzilla.mozilla.org/show_bug.cgi?id=323039 for the relevant >>>> bugs. >>>> >>>>> The value of e.timeStamp *looks* like a UNIX timestamp (milliseconds >>>>> since Jan. 1, 1970 midnight), which is what MDC documentation led me >>>>> to believe it should be. >>>> >>>> The MDC documentation has a certain tencency to be based on the DOM >>>> specs. >>>> :( >>>> >>>>> I think using a JS date object makes the most sense (especially since >>>>> it's easy to go from a date object to either a date/time string OR >>>>> unix timestamp). But if there are sites that expect this to be unix >>>>> timestamp or date string, then this would break them. >>>> >>>> I would be very surprised if such sites exist, honestly, given the above >>>> situation with Gecko. >>> >>> What is the use case for this feature? >> >> This is indeed a good question >> >>> >>> It doesn't seem very hard to implement, but there's certainly a >>> performance cost to getting the current time for each event. >> >> It is always possible to implement the feature by returning 0. >> Both D2E and D3E allow that. > > That seems very strange to me. Optional features don't really have a > good track record. Is there a reason to believe that sites won't > depend on this feature if it's available in one or two popular > browsers? Unless the feature is so useless that no-one will use it, > but in that case it seems better to just remove it. > > / Jonas > > A real usecase for timestamps would be great. Otherwise we could deprecate them and browsers could make .timeStamp no-op which has always value 0. -Olli |
|
|
Re: DOMTimeStamp interface not defined in L3 events...Hi, Folks-
Olli Pettay wrote (on 10/5/09 12:29 PM): > On 10/5/09 9:07 PM, Jonas Sicking wrote: >> On Mon, Oct 5, 2009 at 2:10 AM, Olli Pettay<Olli.Pettay@...> >>> It is always possible to implement the feature by returning 0. >>> Both D2E and D3E allow that. >> >> That seems very strange to me. > Yeah, that is very strange. That's a polite assessment. > Optional features don't really have a >> good track record. Is there a reason to believe that sites won't >> depend on this feature if it's available in one or two popular >> browsers? Unless the feature is so useless that no-one will use it, >> but in that case it seems better to just remove it. >> >> / Jonas >> >> > A real usecase for timestamps would be great. > Otherwise we could deprecate them and browsers could make .timeStamp > no-op which has always value 0. What about syncing between 2 instantiations on 2 different browsers for, say, a shared whiteboard. Maybe I'm being dense, but why can't browsers get the system clock time? Regards- -Doug Schepers W3C Team Contact, SVG and WebApps WGs |
|
|
Re: DOMTimeStamp interface not defined in L3 events...On Mon, Oct 5, 2009 at 3:40 PM, Doug Schepers <schepers@...> wrote:
>> A real usecase for timestamps would be great. >> Otherwise we could deprecate them and browsers could make .timeStamp >> no-op which has always value 0. > > What about syncing between 2 instantiations on 2 different browsers for, > say, a shared whiteboard. This (and any other usecases I can think of) could likely be achieved by a listener to the event simply requesting the current timestamp from JavaScript when it is fired. And even still, this is only as synchronized as the synchronization of the 2 computers' clocks. > Maybe I'm being dense, but why can't browsers get the system clock time? > I believe the concern is the performance costs associated with getting the current system time for every event. --Jacob |
|
|
Re: DOMTimeStamp interface not defined in L3 events...On Mon, 05 Oct 2009 20:07:37 +0200, Jonas Sicking <jonas@...> wrote:
>> It is always possible to implement the feature by returning 0. >> Both D2E and D3E allow that. > > That seems very strange to me. Optional features don't really have a > good track record. Is there a reason to believe that sites won't > depend on this feature if it's available in one or two popular > browsers? Unless the feature is so useless that no-one will use it, > but in that case it seems better to just remove it. FWIW we (Opera) don't support this. We have had no requests for it (by which I mean that searching for bugs with "event" and "timeStamp" in summary turn up 0 relevant hits) and I'm sure we'd celebrate any removal or deprecation of this oddity :) -- Hallvord R. M. Steen, Core Tester, Opera Software http://www.opera.com http://my.opera.com/hallvors/ |
| Free embeddable forum powered by Nabble | Forum Help |