On Thu, Mar 26, 2015 at 10:51 AM, Vincent St-Amour <stamo...@ccs.neu.edu> wrote:
> This is really cool!
>
> Do you have plans for operations on durations?
>
> Vincent

More vague thoughts than plans.

So-- there's a useful distinction (that comes out of Joda-Time)
between a duration, which is directly convertible to some number of
(nano)seconds, and a period, which contains units like years and
months that have no fixed duration.

The Gregor function `duration-between` actually computes a period,
according to this terminology. This raises a few questions (for me,
anyhow):

- Is a "duration" data structure, distinct from some number of
nanoseconds, useful? In Joda it seems largely a way of (a) adding
convenience functions for translating some number of years, months,
days, etc. into a number of nanoseconds, and (b) converting some fixed
duration to a period. Since both kinds of translation are lossy, I
don't know how useful this is -- all the more so because, if we had
some "period" data structure, we could always provide
`period->nanoseconds`.

- Assuming that "periods" are useful, what operations on them do we
want? Arithmetic, probably; maybe the `period->nanoseconds` function I
just mentioned; maybe convenience functions based on the current time
(e.g., `ago`, `from-now`). Anything else?

- How do we represent a period? The obvious choice:

  (struct period (sign years months ...))

- Then what happens to the interface of `duration-between`? Maybe it
returns a period where non-requested field values are #f. Do I still
request fields by providing a list of symbols? I do like the fact
that, in the current interface, the symbol you pass in to request that
a field appear in the output is the key that you use to access that
field in the result (which is currently an alist). It's not that I
love alists, but I haven't come up with a struct-based interface that
I like better.

So maybe a period just is an alist (as described by the range contract
of `duration-between`)?

I am absolutely open to any thoughts you, or anyone else on the list,
has. Since this conversation might not be of general interest, we
could move it over to gregor's github site and use the issue tracker.

Most of all, thank you for your interest.

-Jon


>
>
>
>
> At Wed, 25 Mar 2015 21:55:31 -0400,
> Jon Zeppieri wrote:
>>
>> I recently uploaded Gregor, a date and time library, to the package server.
>>
>> Features:
>>
>> - representations for and generic operations on:
>>   - dates
>>   - times (as in, time-of-day)
>>   - datetimes (combined date and time)
>>   - moments (combined datetime and IANA/Olson timezone)
>> - date arithmetic
>> - localized formatting and parsing, using CLDR data
>>
>> As you might expect from the name, Gregor uses a (proleptic) Gregorian 
>> calendar.
>>
>> Documentation: http://pkg-build.racket-lang.org/doc/gregor/index.html
>> Source and bug tracking: https://github.com/97jaz/gregor
>>
>> -Jon
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to