dst

c# daylight savings duplicate hour convert to UTC

徘徊边缘 提交于 2019-11-28 21:26:13
I am using TimeZoneInfo to convert between client side wallclock 'Eastern Time' and UTC. My problem is with the 'duplicate' hour that occurs during autumn DST change. During conversion from UTC to Eastern: 2010-11-07 06:00 UTC --> gives 2010-11-07T 01 :00:00-03:30 2010-11-07 07:00 UTC --> gives 2010-11-07T 01 :00:00-03:30 How can I know which is first hour and which is second? DateTime.IsDaylightSavingTime() returns false for both hours, but shouldn't it return true for the first hour? Likewise, how do I store 2010-11-07 01:00:00 -03:30? How can my app convert to UTC since it could be 2010-11

Convert a unixtime to a datetime object and back again (pair of time conversion functions that are inverses)

你离开我真会死。 提交于 2019-11-28 21:11:38
I'm trying to write a pair of functions, dt and ut , that convert back and forth between normal unix time (seconds since 1970-01-01 00:00:00 UTC) and a Python datetime object. If dt and ut were proper inverses then this code would print the same timestamp twice: import time, datetime # Convert a unix time u to a datetime object d, and vice versa def dt(u): return datetime.datetime.fromtimestamp(u) def ut(d): return time.mktime(d.timetuple()) u = 1004260000 print u, "-->", ut(dt(u)) Alas, the second timestamp is 3600 seconds (an hour) less than the first. I think this only happens for very

Getting ZoneId from a SimpleTimeZone

寵の児 提交于 2019-11-28 14:46:51
Using Java I have a SimpleTimeZone instance with GMT offset and daylight saving time information from a legacy system. I would like to retrieve ZoneId to be able to use Java 8 time API. Actually, toZoneId returns a ZoneId without the daylight Saving time infos SimpleTimeZone stz = new SimpleTimeZone( 2 * 60 * 60 * 1000, "GMT", Calendar.JANUARY,1,1,1, Calendar.FEBRUARY,1,1,1, 1 * 60 * 60 * 1000); stz.toZoneId(); First of all, when you do: SimpleTimeZone stz = new SimpleTimeZone(2 * 60 * 60 * 1000, "GMT", Calendar.JANUARY, 1, 1, 1, Calendar.FEBRUARY, 1, 1, 1, 1 * 60 * 60 * 1000); You're creating

What is the System.TimeZoneInfo.IsDaylightSavingTime equivalent in NodaTime?

丶灬走出姿态 提交于 2019-11-28 13:29:42
System.TimeZoneInfo has a method called IsDaylightSavingTime , which takes a DateTime object and returns true if the specified datetime falls in the DST for that timezone. Is there an equivalent function in NodaTime or another way to achieve the same result? You can get this from a ZoneInterval . Here is an extension method that will help. public static bool IsDaylightSavingsTime(this ZonedDateTime zonedDateTime) { var instant = zonedDateTime.ToInstant(); var zoneInterval = zonedDateTime.Zone.GetZoneInterval(instant); return zoneInterval.Savings != Offset.Zero; } Now you can do: zdt

How to detect Ambiguous and Invalid DateTime in PHP?

南楼画角 提交于 2019-11-28 11:11:17
When dealing with local DateTime values provided by a user, it's quite possible to have a time that is either invalid or ambiguous, due to Daylight Saving Time transitions. In other languages and frameworks, there are often methods such as isAmbiguous and isValid , on some representation of the time zone. For example in .NET, there is TimeZoneInfo.IsAmbiguousTime and TimeZoneInfo.IsInvalidTime . Plenty of other time zone implementations have similar methods, or functionality to address this concern. For example, in Python, the pytz library will throw an AmbiguousTimeError or InvalidTimeError

Daylight savings time in Python

烂漫一生 提交于 2019-11-28 11:02:53
I am writing a program which deals a lot with timezones and crossing them. The two things I deal with most are creating a datetime object from "now" and then localizing a naive datetime object. To create a datetime object from now in the pacific timezone, I am currently doing this (python 2.7.2+) from datetime import datetime import pytz la = pytz.timezone("America/Los_Angeles") now = datetime.now(la) Is this correct with regards to DST? If not, I suppose I should be doing: now2 = la.localize(datetime.now()) My question is why? Can anyone show me a case where the first is wrong and the seconds

pytz.astimezone not accounting for daylight savings?

拜拜、爱过 提交于 2019-11-28 10:50:41
On 2013 Jun 1 I expect the "PST8PDT" timezone to behave like GMT+7, as it is daylight savings in that timezone. However, it behaves like GMT+8: >>> import pytz, datetime >>> Pacific = pytz.timezone("PST8PDT") >>> datetime.datetime(2013, 6, 1, 12, tzinfo=Pacific).astimezone(pytz.utc) datetime.datetime(2013, 6, 1, 20, 0, tzinfo=<UTC>) In contrast, on 2013 Jan 1 it behaves (correctly) like GMT+8: >>> datetime.datetime(2013, 1, 1, 12, tzinfo=Pacific).astimezone(pytz.utc) datetime.datetime(2013, 1, 1, 20, 0, tzinfo=<UTC>) What am I doing wrong? Thanks in advance! You can't assign the timezone in

How is java.util.TimeZone daylight info updated?

两盒软妹~` 提交于 2019-11-28 10:33:30
问题 I couldn't find a similar question around, so here it goes. I need to create some alerts and basically identify when a daylight saving time approaches, i.e. next thursday daylight begins Question How does Timezone knows the correct info? I ask that because, for instance, in my country - Brazil - the day is defined one year before when it will happen by government. It could potentially not even exist on a specific year. This probably happens in other countries as well. On Java Doc, the below

Oracle TIMESTAMP WITH TIMEZONE named zone vs offset

China☆狼群 提交于 2019-11-28 10:14:50
In oracle, is the named timezone always stored? I have been testing this column within our system, and in some places the timestamp is shown as: 26-FEB-09 11.36.25.390713 AM +13:00 but other times it's: 26-FEB-09 11.36.25.390713 AM Pacific/Auckland If the value is being stored as the former, does that mean the actual timezone is not being stored? I worry because if a future date is stored with only an offset we might not be able to determine the actual time in the original timezone, because you can determine a offset from a timezone, but not vice versa. Thanks It's pretty easy to test create

Determining remote daylight saving in sql server

て烟熏妆下的殇ゞ 提交于 2019-11-28 08:03:45
问题 I want to determine the if daylight saving time is active or not, but in a region different to where my server is located. My problem is I want to check the daylight saving of London and my server is in Canada; is it possible to find the daylight saving of a different time zone? 回答1: You need to deploy a table of DST and look up the DST time for the region you want. DST are published by various organizations and refreshed periodically. What you need to understand is that DST cannot be