Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
On Thu, Mar 26, 2015 at 3:56 PM, John Clements
cleme...@brinckerhoff.org wrote:

 On Mar 25, 2015, at 6:55 PM, Jon Zeppieri zeppi...@gmail.com wrote:

 I recently uploaded Gregor, a date and time library, to the package server.

 Can I use this instead of SRFI 19? That would be wonderful.

 John Clements

Please do, and let me know what additions or changes you'd like.

-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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jay McCarthy
This is so awesome.

Jay

On Wed, Mar 25, 2015 at 9:55 PM, Jon Zeppieri zeppi...@gmail.com 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.



-- 
Jay McCarthy
http://jeapostrophe.github.io

   Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great.
  - DC 64:33

-- 
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Vincent St-Amour
At Thu, 26 Mar 2015 14:30:28 -0400,
Jon Zeppieri wrote:
 
 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`.

I don't have much expertise in that domain, but having two closely
related but subtly different concepts sounds like a bad idea.

Since, IIUC, periods need to be anchored to a specific point in time,
that would make them a bit more heavyweight to create. I could see
durations being nice for that reason, and their use may not be too
problematic if they're only used up to the week level, up to which there
are reasonable, uniform conversion factors. (I.e. for dealing with
unanchored durations, ignoring leap seconds is probably fine.)

Of course, this could also potentially be adressed by providing a
shortcut for creating periods where one doesn't care about anchoring.

 - 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?

I think arithmetic is really the big one.

 - 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 think a struct that implements `gen:dict` would be a nicer interface.
I don't really like `duration-between`'s current interface.

Again, really cool work!

Vincent

-- 
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
On Thu, Mar 26, 2015 at 4:57 PM, Vincent St-Amour stamo...@ccs.neu.edu wrote:
 At Thu, 26 Mar 2015 14:30:28 -0400,
 Jon Zeppieri wrote:


[ snip]

 Since, IIUC, periods need to be anchored to a specific point in time,
 that would make them a bit more heavyweight to create. I could see
 durations being nice for that reason, and their use may not be too
 problematic if they're only used up to the week level, up to which there
 are reasonable, uniform conversion factors. (I.e. for dealing with
 unanchored durations, ignoring leap seconds is probably fine.)

The anchor really only needs to be supplied when you do something with
a period -- so it doesn't need to be part of the data structure. You
can carry around a bucket that says 5 years, 3 weeks, and 40 hours,
but the precise number of seconds inside the bucket is indeterminate
until you pour it over a date-provider. (No, not a great metaphor.)


 - 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?

 I think arithmetic is really the big one.

Yep.


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

 I think a struct that implements `gen:dict` would be a nicer interface.
 I don't really like `duration-between`'s current interface.

I like that idea.


 Again, really cool work!

 Vincent

Thanks!

-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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Robby Findler
On Thu, Mar 26, 2015 at 4:13 PM, Jon Zeppieri zeppi...@gmail.com wrote:
 You
 can carry around a bucket that says 5 years, 3 weeks, and 40 hours,
 but the precise number of seconds inside the bucket is indeterminate
 until you pour it over a date-provider. (No, not a great metaphor.)

I have a feeling I'm going to regret this :), but why can't you know
the precise number of seconds in that case? Is it because of leap
years? Would 3 weeks and 40 hours always be a precise number of
seconds?

Robby

-- 
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
On Thu, Mar 26, 2015 at 5:27 PM, Robby Findler
ro...@eecs.northwestern.edu wrote:
 On Thu, Mar 26, 2015 at 4:13 PM, Jon Zeppieri zeppi...@gmail.com wrote:
 You
 can carry around a bucket that says 5 years, 3 weeks, and 40 hours,
 but the precise number of seconds inside the bucket is indeterminate
 until you pour it over a date-provider. (No, not a great metaphor.)

 I have a feeling I'm going to regret this :), but why can't you know
 the precise number of seconds in that case? Is it because of leap
 years? Would 3 weeks and 40 hours always be a precise number of
 seconds?

 Robby


Yes, leap years.

3 weeks and 40 hours will always have a fixed number of seconds, but
not 5 years. Similarly, N months doesn't have a fixed duration,
because months can be 28, 29, 30, or 31 days long.

-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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Vincent St-Amour
This is really cool!

Do you have plans for operations on durations?

Vincent




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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
Gregor shares the near-universal disdain for UTC exhibited by operating systems 
and date/time libraries alike.

Seriously, though: Gregor doesn't keep UTC time, so there are no leap seconds. 
I mentioned in the docs that if there's a real demand for UTC, I'll implement 
it.

- Jon




 On Mar 26, 2015, at 5:41 PM, Jens Axel Søgaard jensa...@soegaard.net wrote:
 
 2015-03-26 22:30 GMT+01:00 Jon Zeppieri zeppi...@gmail.com:
 On Thu, Mar 26, 2015 at 5:27 PM, Robby Findler
 
 Would 3 weeks and 40 hours always be a precise number of
 seconds?
 
 Robby
 
 What about leap seconds?
 
 /Jens Axel

-- 
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Neil Van Dyke
BTW, the ISO 8601 standard (I don't mean the trivial ISO 8601 date/time 
format everybody knows) has done a lot on concepts you might want to 
look at.  Beware that ISO 8601 is big, and there is some baffling stuff 
included, but you can't always tell what is important.


One thing I can tell you is that the non-Gregorian week-date calendar 
actually does get used, even in the US (regulatory purposes, no less), 
and there is actually Racket server code in production right now that 
has to do week-dates.


(If looking at ISO 8601, be sure to check out the fun pathological set 
of partial date and time formats, in the three calendars that they 
support.  I implemented it years ago, but it got back-burnered before I 
finished implementing arbitrary arithmetic between different calendars 
and different time point resolutions.)


Neil V.

--
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
I've used a library like this before
[https://github.com/jeremyw/stamp], and realized that there were two
things I didn't like about it: (1) potential ambiguity in the
(user-)chosen exemplar date/time and (2) my tendency to mistake the
exemplar date for an actual piece of data in the program. Go's
approach probably helps with both problems.


On Thu, Mar 26, 2015 at 6:43 PM, Sam Tobin-Hochstadt
sa...@cs.indiana.edu wrote:


 On Thu, Mar 26, 2015 at 4:26 PM Jon Zeppieri zeppi...@gmail.com wrote:

 On Thu, Mar 26, 2015 at 3:56 PM, John Clements
 cleme...@brinckerhoff.org wrote:
 
  On Mar 25, 2015, at 6:55 PM, Jon Zeppieri zeppi...@gmail.com wrote:
 
  I recently uploaded Gregor, a date and time library, to the package
  server.
 
  Can I use this instead of SRFI 19? That would be wonderful.
 
  John Clements

 Please do, and let me know what additions or changes you'd like.


 One cool feature I've seen [1] is formatting dates based on existing
 formatted dates. IOW, something like this:

 (~t (today) 1/1/2000)

 [1] Go does a variant of this but it looks like it has to be one specific
 date in 2006: http://golang.org/pkg/time/#pkg-constants

-- 
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
On Thu, Mar 26, 2015 at 5:30 PM, Jon Zeppieri zeppi...@gmail.com wrote:

 3 weeks and 40 hours will always have a fixed number of seconds...

And this is because Gregor isn't faithful to UTC, of course.
Otherwise, this wouldn't be true.

-- 
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Robby Findler
On Thu, Mar 26, 2015 at 4:31 PM, Jon Zeppieri zeppi...@gmail.com wrote:
 On Thu, Mar 26, 2015 at 5:30 PM, Jon Zeppieri zeppi...@gmail.com wrote:

 3 weeks and 40 hours will always have a fixed number of seconds...

 And this is because Gregor isn't faithful to UTC, of course.
 Otherwise, this wouldn't be true.

Right; I noticed that in the docs. Sorry, should have mentioned that.

Robby

-- 
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread 'John Clements' via users-redirect

On Mar 25, 2015, at 6:55 PM, Jon Zeppieri zeppi...@gmail.com wrote:

 I recently uploaded Gregor, a date and time library, to the package server.

Can I use this instead of SRFI 19? That would be wonderful.

John Clements


 
 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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
On Thu, Mar 26, 2015 at 5:27 PM, Robby Findler
ro...@eecs.northwestern.edu wrote:
 On Thu, Mar 26, 2015 at 4:13 PM, Jon Zeppieri zeppi...@gmail.com wrote:
 You
 can carry around a bucket that says 5 years, 3 weeks, and 40 hours,
 but the precise number of seconds inside the bucket is indeterminate
 until you pour it over a date-provider. (No, not a great metaphor.)

 I have a feeling I'm going to regret this :), but why can't you know
 the precise number of seconds in that case? Is it because of leap
 years? Would 3 weeks and 40 hours always be a precise number of
 seconds?

 Robby


Yes, leap years.

3 weeks and 40 hours will always have a fixed number of seconds, but
not 5 years. Similarly, N months doesn't have a fixed duration,
because months can be 28, 29, 30, or 31 days long.

-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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Robby Findler
On Thu, Mar 26, 2015 at 4:13 PM, Jon Zeppieri zeppi...@gmail.com wrote:
 You
 can carry around a bucket that says 5 years, 3 weeks, and 40 hours,
 but the precise number of seconds inside the bucket is indeterminate
 until you pour it over a date-provider. (No, not a great metaphor.)

I have a feeling I'm going to regret this :), but why can't you know
the precise number of seconds in that case? Is it because of leap
years? Would 3 weeks and 40 hours always be a precise number of
seconds?

Robby

-- 
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jens Axel Søgaard
2015-03-26 22:30 GMT+01:00 Jon Zeppieri zeppi...@gmail.com:
 On Thu, Mar 26, 2015 at 5:27 PM, Robby Findler

  Would 3 weeks and 40 hours always be a precise number of
 seconds?

 Robby

What about leap seconds?

/Jens Axel

-- 
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Robby Findler
On Thu, Mar 26, 2015 at 4:31 PM, Jon Zeppieri zeppi...@gmail.com wrote:
 On Thu, Mar 26, 2015 at 5:30 PM, Jon Zeppieri zeppi...@gmail.com wrote:

 3 weeks and 40 hours will always have a fixed number of seconds...

 And this is because Gregor isn't faithful to UTC, of course.
 Otherwise, this wouldn't be true.

Right; I noticed that in the docs. Sorry, should have mentioned that.

Robby

-- 
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Neil Van Dyke
BTW, the ISO 8601 standard (I don't mean the trivial ISO 8601 date/time 
format everybody knows) has done a lot on concepts you might want to 
look at.  Beware that ISO 8601 is big, and there is some baffling stuff 
included, but you can't always tell what is important.


One thing I can tell you is that the non-Gregorian week-date calendar 
actually does get used, even in the US (regulatory purposes, no less), 
and there is actually Racket server code in production right now that 
has to do week-dates.


(If looking at ISO 8601, be sure to check out the fun pathological set 
of partial date and time formats, in the three calendars that they 
support.  I implemented it years ago, but it got back-burnered before I 
finished implementing arbitrary arithmetic between different calendars 
and different time point resolutions.)


Neil V.

--
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jay Kominek
On Thu, Mar 26, 2015 at 2:57 PM, Vincent St-Amour stamo...@ccs.neu.edu wrote:
 At Thu, 26 Mar 2015 14:30:28 -0400, Jon Zeppieri wrote:

 On Thu, Mar 26, 2015 at 10:51 AM, Vincent St-Amour stamo...@ccs.neu.edu 
 wrote:
 - 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`.

Having written a bunch of Python stuff using timeinterval, I'm maybe
98% of the time just trying to shift a date/time/datetime by X
milliseconds, or find out how many milliseconds apart two things are.
Representing that as a fancy structure has almost never been useful.
The one or two times it has been handy are easily outweighed by all
the extra typing it has cost me over the years.

 - 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?

 I think arithmetic is really the big one.

I can't remember ever needing to compute how many seconds there were
in some user-friendly period representation. Usually I'm trying to
avoid such things ever becoming seconds, because then I'll end up with
the wrong answer sooner or later.

{,micro,nano}seconds-between has been what I've wanted every time.

On Thu, Mar 26, 2015 at 3:55 PM, Greg Hendershott
greghendersh...@gmail.com wrote:
 - 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?

 1. For scheduling apps people often deal with things like Monday
 every 2 weeks, the 1st and 3rd Wednesday of every month, or the
 last Friday of every month. Maybe Gregor could do that? (Maybe
 parsing and formatting _text_ like that belongs in another package, I
 don't know.)

Some sort of 1st and 3rd wednesday of every month starting from X
sequence generator would be incredible.

Parsing text like that hasn't ever come up for me, but I could imagine
it being useful.

 2. Another useful concept is weekdays. Or more generally (sorry) work
 days. So, a way to specify a set of excluded days (holidays). Of
 course some holidays have weird specifications (the 3rd Thursday of
 November) that could benefit from 1.

Having a package provided implementation of this, and some holiday
checking stuff (maybe with a database of common holidays) would
simplify even further some of the programs I've got on my
rewrite-in-racket list.



Thanks so much for making this!

-- 
Jay Kominek

-- 
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.


Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
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.