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