Re: Proposal: Duration

2019-03-04 Thread Isiah Meadows
Alexandre: I feel it's only *related* to dates and times:

- Dates and times refer to absolute points.
- Durations would refer to distances between two dates and/or times.

However, I do feel this should be discussed in
https://github.com/tc39/proposal-temporal. And down this vein, I've
created https://github.com/tc39/proposal-temporal/issues/109 just now.

Naveen: If you look at that proposal and particularly the issue I
filed, you can see date handling isn't as simple as it looks. There's
an entire database dedicated to localizing just times [1] (source:
[2]), and numeric date handling is a mess all on its own, [3] even if
you just stick with *just* the Gregorian calendar. [4] About the only
portable way to handle a date is to just do a bunch of UTC offsets to
the start of January 1, 1970, but even that has glitches in the form
of leap seconds. [5]

Or to put it simply: Date handling is hard.

[1]: https://www.iana.org/time-zones
[2]: https://github.com/eggert/tz
[3]: https://en.wikipedia.org/wiki/Calendar_date
[4]: https://en.wikipedia.org/wiki/Gregorian_calendar
[5]: https://en.wikipedia.org/wiki/Leap_second

-

Isiah Meadows
cont...@isiahmeadows.com
www.isiahmeadows.com


On Mon, Mar 4, 2019 at 4:30 PM Mark Davis ️  wrote:
>
> Sadly, time is not that simple. Most people using calendars consider the 
> duration between January 15 and March 15 to be exactly 2 months. But such 
> intervals are a different number of days, hence milliseconds.
>
> Mark
>
>
> On Mon, Mar 4, 2019 at 11:21 AM Naveen Chawla  wrote:
>>
>> I don't like it. Duration is just milliseconds for me.
>>
>> On Mon, 4 Mar 2019 at 18:47 Alexandre Morgaut  
>> wrote:
>>>
>>> Here a proposal to make ECMAScript natively support a Duration Object
>>>
>>> I talked about it a long time ago (2011) on the WHATWG mailing list in the 
>>> context of the Timers API: 
>>> https://lists.w3.org/Archives/Public/public-whatwg-archive/2011Feb/0533.htm
>>>
>>> l think that such a proposal would better take place in the core of the 
>>> language and having worked on a framework date time APIs I tried to give 
>>> this approach a better look.
>>>
>>> ECMAScript natively support Dates since its very first version
>>> It started to support the ISO 8601 string format in edition 5
>>> (15.9.1.15 Date Time String Format )
>>>
>>> Durations like Dates can be very tricky, especially with I18n in mind, but 
>>> the ECMA standard already had to be handled most of the Duration tricky 
>>> part for the Date Object in EMCA 262 & ECMA 402.
>>>
>>> Duration, sometimes called TimeInterval, is a common concept supported by 
>>> most languages or associated standard libs.
>>>
>>> In very short, Duration object would:
>>> - support the ISO syntax in its contructor: new Duration('P6W') // for  
>>> Period 6 Weeks
>>> - allow to handle Date diff operations
>>> - allow to be interpreted by setTimeout() & setInterval()
>>>
>>> Please find below a draft exposing the concept
>>> I'd be very happy if someone from TC39 would be interested to champion it
>>> https://github.com/AMorgaut/proposal-Duration
>>>
>>> Regards,
>>>
>>> Alexandre.
>>> ___
>>> es-discuss mailing list
>>> es-discuss@mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Proposal: Duration

2019-03-04 Thread Gus Caplan
Please take a look at https://github.com/tc39/proposal-temporal

On Mon, Mar 4, 2019 at 3:30 PM Mark Davis ☕️  wrote:

> Sadly, time is not that simple. Most people using calendars consider the
> duration between January 15 and March 15 to be exactly 2 months. But such
> intervals are a different number of days, hence milliseconds.
>
> Mark
>
>
> On Mon, Mar 4, 2019 at 11:21 AM Naveen Chawla 
> wrote:
>
>> I don't like it. Duration is just milliseconds for me.
>>
>> On Mon, 4 Mar 2019 at 18:47 Alexandre Morgaut <
>> alexandre.morg...@gmail.com> wrote:
>>
>>> Here a proposal to make ECMAScript natively support a Duration Object
>>>
>>> I talked about it a long time ago (2011) on the WHATWG mailing list in
>>> the context of the Timers API:
>>> https://lists.w3.org/Archives/Public/public-whatwg-archive/2011Feb/0533.htm
>>>
>>> l think that such a proposal would better take place in the core of the
>>> language and having worked on a framework date time APIs I tried to give
>>> this approach a better look.
>>>
>>> ECMAScript natively support Dates since its very first version
>>> It started to support the ISO 8601 string format in edition 5
>>> (15.9.1.15 Date Time String Format )
>>>
>>> Durations like Dates can be very tricky, especially with I18n in mind,
>>> but the ECMA standard already had to be handled most of the Duration tricky
>>> part for the Date Object in EMCA 262 & ECMA 402.
>>>
>>> Duration, sometimes called TimeInterval, is a common concept supported
>>> by most languages or associated standard libs.
>>>
>>> In very short, Duration object would:
>>> - support the ISO syntax in its contructor: new Duration('P6W') // for
>>> Period 6 Weeks
>>> - allow to handle Date diff operations
>>> - allow to be interpreted by setTimeout() & setInterval()
>>>
>>> Please find below a draft exposing the concept
>>> I'd be very happy if someone from TC39 would be interested to champion it
>>> https://github.com/AMorgaut/proposal-Duration
>>>
>>> Regards,
>>>
>>> Alexandre.
>>> ___
>>> es-discuss mailing list
>>> es-discuss@mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Proposal: Duration

2019-03-04 Thread Mark Davis ☕️
Sadly, time is not that simple. Most people using calendars consider the
duration between January 15 and March 15 to be exactly 2 months. But such
intervals are a different number of days, hence milliseconds.

Mark


On Mon, Mar 4, 2019 at 11:21 AM Naveen Chawla  wrote:

> I don't like it. Duration is just milliseconds for me.
>
> On Mon, 4 Mar 2019 at 18:47 Alexandre Morgaut 
> wrote:
>
>> Here a proposal to make ECMAScript natively support a Duration Object
>>
>> I talked about it a long time ago (2011) on the WHATWG mailing list in
>> the context of the Timers API:
>> https://lists.w3.org/Archives/Public/public-whatwg-archive/2011Feb/0533.htm
>>
>> l think that such a proposal would better take place in the core of the
>> language and having worked on a framework date time APIs I tried to give
>> this approach a better look.
>>
>> ECMAScript natively support Dates since its very first version
>> It started to support the ISO 8601 string format in edition 5
>> (15.9.1.15 Date Time String Format )
>>
>> Durations like Dates can be very tricky, especially with I18n in mind,
>> but the ECMA standard already had to be handled most of the Duration tricky
>> part for the Date Object in EMCA 262 & ECMA 402.
>>
>> Duration, sometimes called TimeInterval, is a common concept supported by
>> most languages or associated standard libs.
>>
>> In very short, Duration object would:
>> - support the ISO syntax in its contructor: new Duration('P6W') // for
>> Period 6 Weeks
>> - allow to handle Date diff operations
>> - allow to be interpreted by setTimeout() & setInterval()
>>
>> Please find below a draft exposing the concept
>> I'd be very happy if someone from TC39 would be interested to champion it
>> https://github.com/AMorgaut/proposal-Duration
>>
>> Regards,
>>
>> Alexandre.
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


RE: Proposal: Duration

2019-03-04 Thread Ron Buckton
Personally, I’d love to see something like this included as part of the 
temporal proposal (https://github.com/tc39/proposal-temporal), as I’ve been 
experimenting with something very much like this here: 
https://github.com/rbuckton/temporal/blob/master/src/Duration.ts.

I think a Duration type that meshes with the proposed `plus` method on temporal 
objects would be a huge benefit.

Ron

From: es-discuss  On Behalf Of Alexandre Morgaut
Sent: Monday, March 4, 2019 10:47 AM
To: es-discuss list 
Subject: Proposal: Duration

Here a proposal to make ECMAScript natively support a Duration Object

I talked about it a long time ago (2011) on the WHATWG mailing list in the 
context of the Timers API: 
https://lists.w3.org/Archives/Public/public-whatwg-archive/2011Feb/0533.htm

l think that such a proposal would better take place in the core of the 
language and having worked on a framework date time APIs I tried to give this 
approach a better look.

ECMAScript natively support Dates since its very first version
It started to support the ISO 8601 string format in edition 5
(15.9.1.15 Date Time String Format )

Durations like Dates can be very tricky, especially with I18n in mind, but the 
ECMA standard already had to be handled most of the Duration tricky part for 
the Date Object in EMCA 262 & ECMA 402.

Duration, sometimes called TimeInterval, is a common concept supported by most 
languages or associated standard libs.

In very short, Duration object would:
- support the ISO syntax in its contructor: new Duration('P6W') // for  Period 
6 Weeks
- allow to handle Date diff operations
- allow to be interpreted by setTimeout() & setInterval()

Please find below a draft exposing the concept
I'd be very happy if someone from TC39 would be interested to champion it
https://github.com/AMorgaut/proposal-Duration

Regards,

Alexandre.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Proposal: Duration

2019-03-04 Thread Naveen Chawla
I don't like it. Duration is just milliseconds for me.

On Mon, 4 Mar 2019 at 18:47 Alexandre Morgaut 
wrote:

> Here a proposal to make ECMAScript natively support a Duration Object
>
> I talked about it a long time ago (2011) on the WHATWG mailing list in the
> context of the Timers API:
> https://lists.w3.org/Archives/Public/public-whatwg-archive/2011Feb/0533.htm
>
> l think that such a proposal would better take place in the core of the
> language and having worked on a framework date time APIs I tried to give
> this approach a better look.
>
> ECMAScript natively support Dates since its very first version
> It started to support the ISO 8601 string format in edition 5
> (15.9.1.15 Date Time String Format )
>
> Durations like Dates can be very tricky, especially with I18n in mind, but
> the ECMA standard already had to be handled most of the Duration tricky
> part for the Date Object in EMCA 262 & ECMA 402.
>
> Duration, sometimes called TimeInterval, is a common concept supported by
> most languages or associated standard libs.
>
> In very short, Duration object would:
> - support the ISO syntax in its contructor: new Duration('P6W') // for
> Period 6 Weeks
> - allow to handle Date diff operations
> - allow to be interpreted by setTimeout() & setInterval()
>
> Please find below a draft exposing the concept
> I'd be very happy if someone from TC39 would be interested to champion it
> https://github.com/AMorgaut/proposal-Duration
>
> Regards,
>
> Alexandre.
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Proposal: Duration

2019-03-04 Thread Alexandre Morgaut
Here a proposal to make ECMAScript natively support a Duration Object

I talked about it a long time ago (2011) on the WHATWG mailing list in the
context of the Timers API:
https://lists.w3.org/Archives/Public/public-whatwg-archive/2011Feb/0533.htm

l think that such a proposal would better take place in the core of the
language and having worked on a framework date time APIs I tried to give
this approach a better look.

ECMAScript natively support Dates since its very first version
It started to support the ISO 8601 string format in edition 5
(15.9.1.15 Date Time String Format )

Durations like Dates can be very tricky, especially with I18n in mind, but
the ECMA standard already had to be handled most of the Duration tricky
part for the Date Object in EMCA 262 & ECMA 402.

Duration, sometimes called TimeInterval, is a common concept supported by
most languages or associated standard libs.

In very short, Duration object would:
- support the ISO syntax in its contructor: new Duration('P6W') // for
Period 6 Weeks
- allow to handle Date diff operations
- allow to be interpreted by setTimeout() & setInterval()

Please find below a draft exposing the concept
I'd be very happy if someone from TC39 would be interested to champion it
https://github.com/AMorgaut/proposal-Duration

Regards,

Alexandre.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss