 |
|
| .NET DotNet Forum Index » Visual C# Forum » Converting to TimeZone... |
|
Page 2 of 2 Goto page Previous 1, 2 |
|
| Author |
Message |
| Peter Duniho... |
Posted: Mon Nov 02, 2009 4:20 pm |
|
|
|
Guest
|
Jonathan Wood wrote:
Quote: "Peter Duniho" <no.peted.spam at (no spam) no.nwlink.spam.com> wrote:
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.
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 |
|
|
| Back to top |
|
|
|
| Arne Vajhøj... |
Posted: Fri Nov 06, 2009 9:41 pm |
|
|
|
Guest
|
Jonathan Wood wrote:
Quote: "Arne Vajhøj" <arne at (no spam) vajhoej.dk> wrote:
Well, I sort of have the time zone, just not in the form of a
TimeZoneInfo object.
Can what you have be used to identify the timezone ?
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.
Quote: 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.
Quote: 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.
Quote:
But, no, I don't readily know whether or
not DST should be applied.
According to your original post you had a:
Daylight Savings Time value (bool)
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.
Quote: I have a few ideas on how I might approach the issue and I could
always research all the different time zones and when/how they apply
DST.
It does not work that way.
All timezones with a given offset from UTC does not change to and from
DST at the same time.
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();
}
}
}
Quote: But you need to tell us what information you have.
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 to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Wed Nov 25, 2009 12:14 am
|
|