On May 21, 2013, at 10:05 PM, Lewis wrote:

> Thanks! I didn't know you could construct dates like that.
> 
> According to the docs, the #f argument should give UTC. Unfortunately
> on my machine it gives
> 
> (date* 0 0 12 22 5 2013 3 141 #f 43200 0 "NZST")
> 
> Which is local time for me. Perhaps this is a bug?

Doesn't look that way to me; I read it as 12:00 noon on May 22nd in your time 
zone, which I believe is the same moment as 0:00 midnight UTC.  

However, it also appears that by passing a #f to the seconds->date function, 
you can in fact have a UTC date if you prefer it:


#lang racket

(require racket/date)

(seconds->date (find-seconds 0 0 0 22 05 2013 #f) #f)

Best,

John Clements



> 
> On 22/05/2013, John Clements <cleme...@brinckerhoff.org> wrote:
>> 
>> On May 21, 2013, at 8:51 PM, Lewis wrote:
>> 
>>> When I use string->date in srfi/19, it defaults to my local time zone.
>>> I see from the documentation that one can use "~z" to denote the "time
>>> zone in RFC-822 style". A quick google of RFC-822 suggests "UT" is the
>>> correct abbreviation for UTC.
>>> 
>>> However
>>> 
>>> Welcome to Racket v5.3.4.
>>>> (require srfi/19)
>>>> (string->date "22/05/13/UT" "~d/~m/~y/~z")
>>> string->date: TIME-ERROR type bad-date-format-string: "~d/~m/~y/~z"
>>> context...:
>>>  /usr/lib/racket/collects/srfi/19/time.rkt:1532:0: tm:string->date
>>>  /usr/lib/racket/collects/srfi/19/time.rkt:1569:0: string->date
>>>  /usr/lib/racket/collects/racket/private/misc.rkt:87:7
>>> 
>>> So in short: how - given the day, month and year - can I construct a
>>> date object that's in UTC?
>> 
>> How important is it to you to use srfi/19?
>> 
>> The program below produces the date that you're looking for, if I understand
>> correctly:
>> 
>> 
>> #lang racket
>> 
>> (require racket/date)
>> 
>> (seconds->date (find-seconds 0 0 0 22 05 2013 #f))
>> 
>> 
>> 


____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to