[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Scheme-reports] Date/time package
Peter Bex scripsit:
> I think a comfortable, complete date/time-manipulation is one thing that
> Scheme is sorely lacking. We have SRFI-19, but it is a bit unwieldy and
> not very complete.
I have written up a proposal for WG2 which can be found at
http://trac.sacrideo.us/wg/wiki/TimeAdvancedCowan , with a supplement
on durations and intervals at http://trac.sacrideo.us/wg/wiki/TimePeriodsCowan .
It's based loosely on the Java package JodaTime, but adapted to the nature
of a dynamically typed language. It is certainly comprehensive; how
comfortable it is, is for others to judge.
If anyone's interested, please take a look and comment here.
> (How, for example, do you convert a given time in a
> zone to another zone? How do you go back a month? etc)
(define iso (chronology 'iso))
(define new-york-zone
(chronology-with-time-zone 'America/New_York iso "America/New_York"))
(define dutch-zone
(chronology-with-time-zone 'Europe/Amsterdam iso "Europe/Amsterdam"))
(define new-york-moment (make-date new-york-zone
'((year . 2012) (month-of-year . 5) (day-of-month . 10)
(hour-of-day . 12) (minute-of-hour . 19) (second-of-minute . 30))))
(define dutch-moment (convert-date dutch-zone new-york-moment))
(date-field dutch-moment 'hour-of-day) => 18
(define last-january new-york '((year . 2012) (month-of-year . 1)))
(define last-december (date-increment last-january 'month-of-year -1))
(date-field last-december 'month-of-year) => 12
(date-field last-january 'year) => 2011
--
Schlingt dreifach einen Kreis vom dies! John Cowan <cowan@x>
Schliesst euer Aug vor heiliger Schau, http://www.ccil.org/~cowan
Denn er genoss vom Honig-Tau,
Und trank die Milch vom Paradies. --Coleridge (tr. Politzer)
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports