El 31/03/12 00:19, "Mounir Lamouri" <
mou...@lamouri.fr> escribió:
>Hi,
>
>Following bug 714357 and bug 714358 discussions, I would like to propose
>an API for Time/Clock (we should keep one word I guess).
>
>There are six things we want to handle:
>1. set time
>2. get time
>3. set timezone
>4. get timezone
Probably timezone is part of a setting
>5. be informed when time is changed
>6. be informed when timezone changes
>
>1. Set time
>We can have a navigator.time.set() method that will either take a double
>that will be the number of milliseconds since epoch in the current
>timezone or a Date object. The system time will then be replaced.
Wouldn't it be good to have also nanosecond precision?
On the other hand according to the Ecmascript Spec the number of
milliseconds since the epoch are always independent of the timezone ...
See the getTime method of Date or Date.now()
>
>ISSUES:
>I can think of two questions: should we take the epoch double in UTC
>timezone (I guess not but better to ask) and how should we behave if the
>Date object isn't in the same timezone the system currently is?
I think it is not a good idea to use Date objects for setting time
>Could
>that actually happen unless the timezone has been changed in the
>meantime? If not, we could just throw/ignore. Otherwise, we should
>define a behavior.
>
>2. Get time
>Use Date.
>
>3/4. Set/Get Timezone
>We should use the Settings API to do that.
Yes
>
>5. Time change
>We should fire a change event to navigator.time.
>That event should fire if the timezone has been changed or the time has
>been changed manually. It should not be fired every ms ;)
If timezone changes this can be detected through the Settings API
A time change is worth informing if an alarm is set and the target time
has elapsed
>
>6. Timezone change
>The settings API should allow you to listen to changes.
Yes
>
>The API would look like that:
>
>interface TimeManager {
> void set(Date time);
> void set(double time);
>
> attribute Function? onchange;
>};
>
>interface NavigatorTime {
> readonly attribute TimeManager time;
>};
>
>interface Navigator implements NavigatorTime;
>
>Any feedback?
I don't see setting the time by passing a Date object which to some extent
has some bindings to the timezone. So I would only use the double
>
>Thanks,
>--
>Mounir
>_______________________________________________
>dev-webapi mailing list
>
dev-w...@lists.mozilla.org
>
https://lists.mozilla.org/listinfo/dev-webapi
Este mensaje se dirige exclusivamente a su destinatario. Puede consultar nuestra política de envío y recepción de correo electrónico en el enlace situado más abajo.
This message is intended exclusively for its addressee. We only send and receive email on the basis of the terms set out at
http://www.tid.es/ES/PAGINAS/disclaimer.aspx