Convert clj-time date-time to UTC

2014-06-14 Thread gvim
I want to convert a time specified with a TZ datababse timezone such as America/Caracas into a UTC date-time but I can only find in clj-time from-time-zone and to-time-zone allowing the zone to be specified as a string. I want: (t/some-utc-func (t/date-time 1967 7 31 6 30) (t/time-zone-for-id

Re: Convert clj-time date-time to UTC

2014-06-14 Thread Stephen Gilardi
This is not quite to your exact specification, but should help you to write what you want: user (defn to-utc [dt] (t/to-time-zone dt (t/time-zone-for-offset 0))) #'user/to-utc user (to-utc (t/from-time-zone (t/date-time 1967 7 31 6 30) (t/time-zone-for-id America/Caracas))) #DateTime

Re: Convert clj-time date-time to UTC

2014-06-14 Thread gvim
On 14/06/2014 16:12, Stephen Gilardi wrote: This is not quite to your exact specification, but should help you to write what you want: user (defn to-utc [dt] (t/to-time-zone dt (t/time-zone-for-offset 0))) #'user/to-utc user (to-utc (t/from-time-zone (t/date-time 1967 7 31 6 30)

Re: Convert clj-time date-time to UTC

2014-06-14 Thread Stephen Gilardi
You're welcome. As another small refinement, I noticed that there's a var for the utc timezone: (t/time-zone-for-offset 0) can be replaced with t/utc --Steve On Jun 14, 2014, at 12:49 PM, gvim gvi...@gmail.com wrote: On 14/06/2014 16:12, Stephen Gilardi wrote: This is not

Re: Convert clj-time date-time to UTC

2014-06-14 Thread gvim
On 14/06/2014 17:59, Stephen Gilardi wrote: You're welcome. As another small refinement, I noticed that there's a var for the utc timezone: (t/time-zone-for-offset 0) can be replaced with t/utc I tried t/utc in place of your function but it didn't produce the desired result. gvim --

Re: Convert clj-time date-time to UTC

2014-06-14 Thread Michael Klishin
2014-06-14 20:49 GMT+04:00 gvim gvi...@gmail.com: Can't think why it's not baked into the library, though, as it must be a common requirement. Feel free to submit a pull request and a few tests. The clj-time maintainers are responsive and the library is primarily driven by user feedback at

Re: Convert clj-time date-time to UTC

2014-06-14 Thread gvim
On 14/06/2014 21:59, Michael Klishin wrote: 2014-06-14 20:49 GMT+04:00 gvim gvi...@gmail.com mailto:gvi...@gmail.com: Can't think why it's not baked into the library, though, as it must be a common requirement. Feel free to submit a pull request and a few tests. The clj-time