On Thu, Jan 26, 2017 at 5:20 AM, Oskar Berggren
<
oskar.b...@gmail.com> wrote:
> No, I believe you are mistaken.
>
> There is only one UTC. The UTC is never different. It's value is always the
> same everywhere.
This is exactly correct and is why if you are storing potentially
ambiguous date/time, you are asking for trouble.
> The DateTimeOffset class is used to represent a specific point in time, and
> it can also store that instant associated with an offset. The stored offset
> should always be the stored value's exact difference from UTC.
Never been a fan of handling offsets, per se. That's always a view
concern. In web it is easy enough to convert to local time zone. Even
in a report, I expect it would be easy to receive a time zone in order
to the Utc to local conversion in the handshake.
> So, provided that you grab the local time and the local offset currently in
> effect at that time, when the DTO is constructed, it can always be converted
> to an unambiguous UTC value without knowing the geopolitical time zone
> information.
>
> For the opposite transform, that is, converting a DTO to a local time and
> local offset appropriate to a specific region at that point in time, you
> would need to specify what time zone information to use, obviously. You
> don't need to record the time zone name unless you expressly need to display
> that information later - but I didn't see you do that in your Instant class.
>
> If you ask the computer for the current local DTO, it will return different
> offset depending on if DST is in effect or not. Regardless, the recorded
> value can be unambiguously converted to correct UTC.
>
> You can also have a DTO, add an hour to it, and get a new DTO which
> represents a point in time exactly one hour later - BUT it might not be a
> correctly expressed local time in your intended time zone, because it won't
> update the offset. For that you need help from a time zone. If it's the
> current timezone in effect, it should be easily achieved by just
> roundtripping the DTO to UTC and back.
>
>
> What WILL get you into trouble is if you store the local time _without_
> offset or timezone moniker (which should both change between DST and
> regular), because then some values will be ambiguous. You can't tell if it
> was the last hour of DST or the first hour of standard time.
>
> This is my understanding anyway. Happy to be corrected if I'm wrong.
Agreed. In any event, I always steer clear of this confusion whenever
possible. But what do I know.
> email to
nhusers+u...@googlegroups.com.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "nhusers" group.
> To unsubscribe from this topic, visit
>
https://groups.google.com/d/topic/nhusers/f8qa0bYPHWM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
>
nhusers+u...@googlegroups.com.