Does a wrapper for gmtime exist

99 views
Skip to first unread message

Andrew Gibb

unread,
Jul 27, 2016, 9:32:56 AM7/27/16
to julia-users
Hi,

I'm writing a module for dealing with video timing. The C++ code I'm using as a basis uses gmtime to convert seconds into y:m:d.etc. Does anyone know if this functionality is exposed in Julia anywhere?

I realise I could handle this myself with ccall, I just wanted to check to see if I could avoid duplicating effort.

Thanks

Andy

Isaiah Norton

unread,
Jul 27, 2016, 10:21:05 AM7/27/16
to julia...@googlegroups.com
IIUC, the Julia DateTime object represents UT (milli)seconds, and has converters to/from human-readable dates and local time.

http://docs.julialang.org/en/release-0.4/manual/dates/

Jeffrey Sarnoff

unread,
Jul 27, 2016, 2:54:38 PM7/27/16
to julia-users
Andy,


using UTime

localtime()
2016-07-27T14:41:37.497-04:00

ut()
2016-07-27T18:41:42Z

gmt() # gmt aliases ut
2016-07-27T18:41:45Z

alocaltime = localtime()
2016-07-27T14:42:04.282-04:00
ut(alocaltime)
2016-07-27T18:42:04.282Z

auniversaltime = ut()
2016-07-27T18:42:24Z
localtime(auniversaltime)
2016-07-27T14:42:24-04:00

julia> g=gmt(); g
2016-07-27T18:50:48Z

julia> year(g),month(g),day(g),hour(g),minute(g),second(g)
(2016,7,27,18,50,48)



There is more that one may do using UTime, take a look at the README examples.


It has been some time since I revisited it, so please ask if you have any questions, 
and let me know if there is something that is not now working as it had.
I just ran the examples above in v0.5-.

Regards, 
Jeffrey

Andrew Gibb

unread,
Jul 28, 2016, 8:59:52 AM7/28/16
to julia-users
Thanks both for the suggestions. 
Reply all
Reply to author
Forward
0 new messages