The timestamp function for unix is jtts defined in xt.c. It uses the linux function called localtime. The localtime man 3 page also describes gmtime (for UTC) and mktime (for handling DST).
I am not sure of the correct equivalents for mac though. On Sun, Oct 20, 2013 at 12:53 PM, Pascal Jasmin <[email protected]>wrote: > Should I understand that time in unix returns utc time, and does 6!:0 > return utc time on those systems? > > An update to my previous additions to datetime.ijs, I recommend the > following: > Now_z_ =: 6!:0@:(''"_) > > for some reason, 6!:0 can only accept null as a y argument. > > I would assume the code for 6!:0 is at the bottom of this file: F1 > > https://github.com/openj/core/blob/master/win/jdll.c > > There is a GetSystemTime and GetLocalTime defined for windows at least, > and I assume other platforms too? I cannot seem to locate where that is > defined in the other platforms though. > > I don't know what the right approach might be to modify 6!:0, but allowing > it to accept y as a minutes offset parameter would be a useful kludge. A > parameter that tells it to return localtime, systemtime, or utctime would > seem the most useful. > ________________________________ > From: Jo van Schalkwyk <[email protected]> > To: [email protected] > Sent: Sunday, October 20, 2013 1:30:10 AM > Subject: Re: [Jprogramming] datetime utc and portability > > > From the Linux command line try the following for UNIX time: > > date +%s > > The C header time.h is readily available e.g. here: > http://pubs.opengroup.org/onlinepubs/009696699/basedefs/time.h.html > > Be a bit careful with UNIX time (and UTC generally), which is the number of > seconds since January 1 1970 0:00:00. As you likely know, UTC adds (or > subtracts, but this has not yet occurred) leap seconds unpredictably (to > keep track with UT1), and to compensate for this there is what can only be > described as a groundhog second as the leap second is added at the end of > the day and then the clock ticks backwards for a second. With positive leap > seconds, some Unix time numbers are therefore ambiguous; in addition some > systems may not conform to the POSIX standard. > > There has been a proposal to fix UTC, but the Brits seem to be digging > their heels in. (Personal view: GPS time makes more sense, as it ticks > monotonically and is now readily available). > > Regards Jo. > > > On 20 October 2013 15:58, Ric Sherlock <[email protected]> wrote: > > > I agree it would be great to make these additions to the addon > > cross-platform. I'm also clueless on the best ways to do this outside > > Windows (which is why they aren't there already ;)) > > Anybody have any advice? > > > > > > On Sun, Oct 20, 2013 at 1:37 PM, Pascal Jasmin <[email protected] > > >wrote: > > > > > adding 4 functions to this file: > > > > > > ~addons/types/datetime/datetime.ijs > > > > > > > > > Now_z_ =: 6!:0 > > > utcBIAS_z_ =: 0,~ >1{ getTimeZoneInfo_rgsdatetime_ '' > > > utc_z_ =: tsPlus&utcBIAS > > > utcnow_z_ =: utc@:Now > > > > > > > > > utcBIAS > > > 300 0 > > > this gives a utc adjusted current local time: > > > utcnow '' > > > 2013 10 20 1 9 21.346 > > > > > > utcBIAS relies on the windows api. Though its a noun set once at > > startup, > > > It's kludgy in case of running after a DST change or other system clock > > > change. > > > > > > > > > Is there a cygwin (or other windows) api call to get utctime, that > would > > > be easily portable to unix/mac and smartphones? > > > > > > If not, do each of the platforms have a command line or dll call to set > > > utcBIAS? > > > > > > which approach would be recommended? > > > ---------------------------------------------------------------------- > > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
