A user sent the following comment on my "time" post.
THX ...
>But Dennis, doesn't this assume that one's computer is in Mountain
>Time Zone (and set as such)?
Yes ... I did not make this clear.
The original poster and I
are in the same time zone [Mountain].
The UNIX date [ %s ] returns
seconds since '00:00:00 1970-01-01 UTC'
^^^
There is an 'offset' of 7 hours.
>Whereas, I pre-set my computer to UTC
>time so I don't want the -0700; nor would
>anyone else outside our time zone.
Correct.
--- My original intent was to illustrate the use of "ut_inv_calendar". D > > >On Mar 9, 2006, at 1:22 PM, Dennis Shea wrote: > >> Hello >> >> Earlier I responded to a query regarding about NCL's >> "systemfunc" and the Unix "date" utility. >> >> I thought it might be good to add a comment >> about NCL's "ut_inv_calendar" >> >> http://www.ncl.ucar.edu/Document/Functions/Built-in/ >> ut_inv_calendar.shtml >> >> and how it relates to the Unix "date" utility. >> >> ==== Original response >> >> ncl > Sdatetime = "'2/26/2006 9:14:37 AM'" >> ncl > time = systemfunc("date -d " +Sdatetime+ " '+%s'") >> ncl > print(time) >> >> Variable: time >> Type: string >> [snip] >> (0) 1140970477 >> >> ==== >> man date >> >> will yield the following information [edited] >> >> %s seconds since '00:00:00 1970-01-01 UTC' (a GNU extension) >> >> The %s qualifier is a GNU extension which returns >> a number [here, returned as a variable of type "string"]. >> This number represents the seconds since 1970-01-01 >> >> ==== >> >> The same information can be attained using "ut_inv_calendar" >> but it requires an additional bit of information. >> >> By example: >> >> ncl > units = "seconds since 1970-1-1 00:00:0.0" >> ncl > TIME = ut_inv_calendar(2006, 2, 26 ,9 , 14, 37.0 ,units, 0) >> ncl > print(TIME) >> >> Variable: TIME >> Type: double >> units : seconds since 1970-1-1 00:00:0.0 >> (0) 1140945277 >> >> Note: this returns a variable of type double. >> >> Also, I'm sure the reaction is "Hey, that's not the same number" >> It is different by 25200 seconds [= 1140970477-1140945277] >> >> Ummm, using a super computer one can determine that >> 7*3600 just happens to be 25200 >> >> Well, the additional qualifier for the unit is >> >> ncl > units = "seconds since 1970-1-1 00:00:0.0 -7:00" >> ncl > Time = ut_inv_calendar(2006, 2, 26 ,9 , 14, 37.0 ,units, 0) >> ncl > print(Time) >> >> Variable: Time >> Type: double >> units : seconds since 1970-1-1 00:00:0.0 7:00 >> (0) 1140970477 >> >> >> ===== >> >> Hope this helps .... >> >> D >> >> _______________________________________________ >> ncl-talk mailing list >> ncl-talk_at_ucar.edu >> http://mailman.ucar.edu/mailman/listinfo/ncl-talk _______________________________________________ ncl-talk mailing list ncl-talk_at_ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Thu Mar 09 2006 - 17:09:11 MST
This archive was generated by hypermail 2.2.0 : Thu Mar 09 2006 - 17:28:14 MST