[Glass] understanding the DateTime instance creation API

PAUL DEBRUICKER via Glass glass at lists.gemtalksystems.com
Fri Jul 15 12:47:24 PDT 2016


I'm trying to create a DateTime in a 3.3.1 stone set to use UTC as its current & default timezone. 

When I specify the year, month, day, hour, minute, second and time zone I sometimes wind up with DateTimes I don't understand.  


As an example if I run the below code the two ISO8601 strings that print are for UTC '2016-07-15T10:10:10+0000' and for PST '2016-07-15T17:10:10-0700'.   


I think the PST ISO8601 string generated by GemStone should be  '2016-07-15T10:10:10-0700'


If I then go to another platform e.g. wolframalpha.com and convert from the ISO strings to Unix time, the difference between the UTC ISO8601 string (1468577410 in unix time) and the GemStone generated PST ISO8601 string (1468627810 in unix time) is greater (14 hours) than the difference in their time zone offsets (7 hours).  


What am I doing wrong?  IT seems like I can only reliably specify a DateTime by setting the year, month, day, hour, minute, second and time zone if I use UTC as the time zone.  

Thanks for any guidance you can provide.

Paul




| yr month day hour min second utc pst utcTime pstTime |
  yr := 2016.
  month := 7.
  day := 15.
  hour := 10.
  min := 10.
  second := 10.
  utc := TimeZone named: 'UTC'.
  pst := TimeZone named: 'America/Los_Angeles'.

  utcTime := DateTime
    newWithYear: yr
    month: month
    day: day
    hours: hour
    minutes: min
    seconds: second
    timeZone: utc.

  pstTime := DateTime
    newWithYear: yr
    month: month
    day: day
    hours: hour
    minutes: min
    seconds: second
    timeZone: pst.

  ^ Array
    with: (Array with: utcTime with: utcTime hour with: utcTime asStringISO8601)
    with: (Array with: pstTime with: pstTime hour with: pstTime asStringISO8601)


More information about the Glass mailing list