<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Tim,<div><br></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 18, 2018 at 6:04 PM Tim Johnson <<a href="mailto:digit@sonic.net" target="_blank">digit@sonic.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I am very grateful to see the discussions about timezones on the list <br>
recently, because I just got hit by it today.<br>
<br>
I couldn't figure out why a Set containing Date objects didn't properly <br>
detect membership of a Date which was clearly present in the Set. It was <br>
because, I realize now, the Date objects in the Set had an offset of  <br>
-0:07:00:00 (they are created by DateAndTime>>#now), and Dates created <br>
by e.g. "Date today" or "Date yesterday" either have no offset or the <br>
offset is 0:00:00:00.  I have found the comment in Timespan <br>
class>>#defaultOffset -- but it does not encourage me that I could <br>
change my defaultOffset to help myself.<br>
<br>
In my tests (code snippet below), if I make an OrderedCollection from <br>
the Set, the OrderedCollection can find the date object, even though the <br>
Set can't.<br>
<br>
In the Mean Time (get it?), can I create Dates with offsets?  <br>
"(DateAndTime now - 1 day) asDate" works...?  Or are there any other <br>
workarounds?  Should I walk away from Date and use something else?<br>
<br>
Thanks!<br>
<br>
(in a Workspace)<br>
| dates |<br>
dates := Set newFrom: { Date yesterday. Date tomorrow.  DateAndTime now <br>
asDate }.<br>
dates includes: (Date year: 2018 month: 10 day: 18).   "=> false"<br>
dates asOrderedCollection includes: (Date year: 2018 month: 10 day: 18). <br>
  "=> true"<br></blockquote><div><br></div><div>If you load the latest proposed fix that we are talking about (Chronology-Core-cmm.15.mcz from the inbox), the results do change:</div><div><br></div><div>(in a Workspace)</div><div>| dates |</div><div>dates := Set newFrom: { Date yesterday. Date tomorrow.  DateAndTime now asDate }.</div><div>dates includes: (Date year: 2018 month: 10 day: 19).   "=> false" "=> false"</div><div>dates asOrderedCollection includes: (Date year: 2018 month: 10 day: 19). "=> true"  "=> false" </div><div><br></div><div>(first results pre-load, second results post-load). (changed your example for today - otherwise you get true for both questions)</div><div><br></div><div>This change doesn't fix what you are getting - but at least the results are consistent.  The issue is that a generic time-zone-less date is not the same thing as a date with a specific timezone.  The current code mostly made this true (as shown in the OrderedCollection test) but not fully (as shown in your Set test).</div><div><br></div><div>As Chris Muller pointed out, if you send #stripTimezone with the new fix to your array of dates before putting them into the set, I think you will get what you want:</div><div><br></div><div><div>(in a Workspace)</div><div>| dates |</div><div>dates := Set newFrom: ( { Date yesterday. Date tomorrow.  DateAndTime now asDate } collect: #stripTimezone ).</div><div>dates includes: (Date year: 2018 month: 10 day: 19). "true"</div><div>dates asOrderedCollection includes: (Date year: 2018 month: 10 day: 19). "true"</div></div><div><br></div><div>Would it be convenient for you to try out the proposed Chronology fix in your case (with or without the #stripTimezone), and report back if this works well for you?  I'd like to make dates work like we all think they should.</div><div><br></div><div>-cbc</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
(in an inspector on a Set of dates with offsets)<br>
| a m |<br>
a := Date year: 2018 month: 10 day: 17.<br>
self includes: a.                               "-> false<br>
self like: a.                                   "-> nil"<br>
self asOrderedCollection includes: a.  "-> true"<br>
m := self array at: 4.          "-> 17 October 2018"<br>
m start offset.                         "-> -0:07:00:00"<br>
a start offset                          "-> 0:00:00:00"<br>
<br>
<br>
</blockquote></div></div></div></div>