Converting to TimeZone

  • Thread starter Thread starter Jonathan Wood
  • Start date Start date
Peter Duniho said:
As far as whether I can let it go, I have. I see no point in making any
further attempts to help Jonathan, and I'm not going to.

For the record, I accept your initial intention was to be helpful. I know I
can be ornery, but I'm really not trying make enemies here. For whatever
reason, we weren't communicating and I'd prefer to leave it at that. It can
be frustrating but no hard feelings on this end.

Jonathan
 
Jonathan said:
For the record, I accept your initial intention was to be helpful. I
know I can be ornery, but I'm really not trying make enemies here. For
whatever reason, we weren't communicating and I'd prefer to leave it at
that. It can be frustrating but no hard feelings on this end.

None here either. I guess that just leaves Mark. :)

I'm sorry we weren't able to figure out what each other was talking
about. I suspect there's an important and useful solution to your
problem here, but it will have to remain unknown for the time being.

Pete
 
Jonathan said:
I'm sorry. I thought I had been very clear about what I had. At this
point in time, I have a UTC offset and a DST flag. Does that identify a
time zone?
No.

If not, what other information do I need?

To get timezone you need the name of it.

As indicated in previous post then you need either timezone or
standard offset from UTC + extra offset id DST + info on whether
the time being converted is in DST or not.
And if the only way
in the Universe to calculate a local time requires a TimeZoneInfo
object, what SQL Server data type does that correspond to?

None. But you can obviously store the timezone name as a VARCHAR.

Latest SQLServer allow you to store date time with
timezone info embedded.
Yes, I said that because that was the truth. But a DST flag only tells
me if the location observes DST. It doesn't tell me if DST is in effect
at that particular date.

I misunderstood that to mean for the specific date.
Well, if I researched all the different time zones and when/how they
applied DST, then I'd know the times they changed, no?

Yes.

But you can get two timezone with the same UTC offset that changes
at different dates.

Check with:

using System;
using System.Linq;

namespace E
{
public class Program
{
public static void Main(string[] args)
{
foreach(TimeZoneInfo tz in
TimeZoneInfo.GetSystemTimeZones().OrderBy(tz => tz.BaseUtcOffset))
{
Console.WriteLine(tz.DisplayName + " offset=" +
tz.BaseUtcOffset + " DST=" + tz.SupportsDaylightSavingTime);
foreach(TimeZoneInfo.AdjustmentRule rule in
tz.GetAdjustmentRules())
{
Console.WriteLine(" for " +
rule.DateStart.ToString("yyyy") + " to " + rule.DateEnd.ToString("yyyy") +
" : start=" +
rule.DaylightTransitionStart.Day + "/" +
rule.DaylightTransitionStart.Month + " end=" +
rule.DaylightTransitionEnd.Day + "/" + rule.DaylightTransitionEnd.Month
+ " add=" + rule.DaylightDelta);
}
}
Console.ReadKey();
}
}
}
Can you clarify what part of a date (DateTime), a UTC offset (double),
and a DST flag (bool) I have been unclear on? Thanks.

What DST flag was.

Arne
 
Back
Top