moment->date or moment ... -> ... epoch-seconds

32 views
Skip to first unread message

Geoffrey Knauth

unread,
Sep 22, 2016, 1:55:11 PM9/22/16
to Racket Users
I was using Racket's date. Then I found it was creating a local time when I needed UTC. So I started using moments from (require gregor). Now I'm trying to figure out how to get either a regular date from a moment, or better, how I can get epoch seconds (from 1970-01-01T00:00:00Z) from a moment. I suppose I could compute the since-epoch seconds difference myself, I just don't know if it's in there already and I just missed it.

Geoff

Geoffrey Knauth

unread,
Sep 22, 2016, 2:14:36 PM9/22/16
to Racket Users
I solved my immediate problem by going back to dates and using:

(seconds->date secs-n [local-time?]) → date*?
secs-n : real?
local-time? : any/c = #t

and supplying #f as local-time.

Jack Firth

unread,
Sep 22, 2016, 3:11:06 PM9/22/16
to Racket Users
On Thursday, September 22, 2016 at 10:55:11 AM UTC-7, Geoffrey Knauth wrote:
> I was using Racket's date. Then I found it was creating a local time when I needed UTC. So I started using moments from (require gregor). Now I'm trying to figure out how to get either a regular date from a moment, or better, how I can get epoch seconds (from 1970-01-01T00:00:00Z) from a moment. I suppose I could compute the since-epoch seconds difference myself, I just don't know if it's in there already and I just missed it.
>
> Geoff

I believe ->posix[1] is the function you're looking for

[1] https://docs.racket-lang.org/gregor/datetime-provider.html?q=gregor#%28def._%28%28lib._gregor%2Fmain..rkt%29._-~3eposix%29%29

Reply all
Reply to author
Forward
0 new messages