[Glass] understanding the DateTime instance creation API
Dale Henrichs via Glass
glass at lists.gemtalksystems.com
Fri Jul 15 14:35:21 PDT 2016
Paul,
I've submitted bug46315, because it definitely looks like DateTime is
broken.
I've expanded your example to include DateAndTime results and I believe
that DateAndTime is getting the correct answers. Also DateAndTime has
the default printString and parsing methods that you desire.
Here are the results:
1@ -> anArray( DateTime, 15/07/2016 03:10:10, 3,
'2016-07-15T03:10:10+0000', )
2@ -> anArray( DateAndTime, 2016-07-15T10:10:10+00:00, 10,
'2016-07-15T10:10:10+00:00', )
3@ -> anArray( DateTime, 15/07/2016 10:10:10, 10,
'2016-07-15T10:10:10-0700', )
4@ -> anArray( DateAndTime, 2016-07-15T10:10:10-07:00, 10,
'2016-07-15T10:10:10-07:00', )
and the code:
| yr month day hour min second utc pst utcTime pstTime utcAndTime
pstAndTime |
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.
utcAndTime := DateAndTime
year: yr
month: month
day: day
hour: hour
minute: min
second: second
offset: 0 hours.
pstTime := DateTime
newWithYear: yr
month: month
day: day
hours: hour
minutes: min
seconds: second
timeZone: pst.
pstAndTime := DateAndTime
year: yr
month: month
day: day
hour: hour
minute: min
second: second
offset: -7 hours.
^ {(Array
with: utcTime class
with: utcTime
with: utcTime hour
with: utcTime asStringISO8601).
(Array
with: utcAndTime class
with: utcAndTime
with: utcAndTime hour
with: utcAndTime asString).
(Array
with: pstTime class
with: pstTime
with: pstTime hour
with: pstTime asStringISO8601).
(Array
with: pstAndTime class
with: pstAndTime
with: pstAndTime hour
with: pstAndTime asString)}
More information about the Glass
mailing list