dst

Convert somebody's local time to the UTC time

别说谁变了你拦得住时间么 提交于 2019-12-10 03:54:02
问题 i'm a little lost in the timezone :) I have data stored with the time in UTC. The server is in the Netherlands, so we live in utc+1 (now, with daylightsavingtime, in utc + 2) Now a client says: give me the data from august 5th. So i have to calculate the utc time from 'his time'. For that i have to know: what is your utc offset (we stored that in his profile, let's say utc -6) are you in daylightsavingtime (because then we have to add +1 and make the utc offset -5) Then my questions: Can i

Offset time for DST in one specific timezone using JavaScript

不打扰是莪最后的温柔 提交于 2019-12-10 03:54:00
问题 I need to offset the time by an hour if it's currently DST in the Pacific Time Zone. How can I determine the current daylight savings status of the Pacific Time Zone, regardless of the user's local timezone? Here's what I have so far. "dst" in line 4 is just a placeholder for a function that would tell me if daylight savings time is active in that zone. function checkTime() { var d = new Date(); var hour = d.getUTCHours(); var offset = dst ? 7 : 8; // is pacific time currently in daylight

Resolving AmbiguousTimeError from Django's make_aware

天大地大妈咪最大 提交于 2019-12-09 14:40:56
问题 I have a code as follows: from django.utils.timezone import get_current_timezone, make_aware make_aware(some_datetime, get_current_timezone()) The make_aware call occasionally raises AmbiguousTimeError: 2013-11-03 01:23:17 I know from the Django docs that this is a daylight savings problem, and that this timestamp is in fact ambiguous. Now how do i resolve it (say to the first of the two possible times this could be)? 回答1: Prophylactics You should avoid naive datetimes in the first place

Python - From DST-adjusted local time to UTC

梦想与她 提交于 2019-12-09 11:20:29
问题 A specific bank has branches in all major cities in the world. They all open at 10:00 AM local time. If within a timezone that uses DST, then of course the local opening time also follows the DST-adjusted time. So how do I go from the local time to the utc time. What I need is a function to_utc(localdt, tz) like this: Arguments: localdt: localtime, as naive datetime object, DST-adjusted tz: timezone in the TZ-format, e.g. 'Europe/Berlin' Returns: datetime object, in UTC, timezone-aware EDIT:

Does TimeZoneInfo take DST into consideration?

不羁的心 提交于 2019-12-08 15:07:23
问题 Does C# take Daylight savings time into consideration when converting between timezones? I have a source date which is in the current time in London, and I want to convert it to my timezone (CET). Here's the code I'm using. DateTime time = DateTime.ParseExact(timeString, "HH:mm", null); time = DateTime.SpecifyKind(time, DateTimeKind.Unspecified); //Convert it to the right timezone. It is currently in GMT TimeZoneInfo gmt = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time"); TimeZoneInfo

xslt timezone conversion with daylight saving

旧时模样 提交于 2019-12-08 13:31:16
问题 I am working with xslt and using the fn:current-dateTime( ) to get the current date time (https://www.w3.org/TR/xpath-functions/#func-current-dateTime). The time returned is in UTC. I need to convert this to PST. I see that the fn:adjust-dateTime-to-timezone (http://www.xqueryfunctions.com/xq/fn_adjust-datetime-to-timezone.html) can be used to perform the timezone conversion. But i see that this function accepts the timeZone argument in the form of offset, i.e -PT8H for Pacific timezone while

Insert time with timezone daylight savings

烈酒焚心 提交于 2019-12-08 10:47:10
问题 I would like to insert time data type in postgresql that includes the timezone and is aware of daylight savings time. This is what I have done: CREATE TABLE mytable( ... start_time time(0) with time zone, end_time time(0) with time zone ) INSERT INTO mytable(start_time, end_time) VALUES(TIME '08:00:00 MST7MDT', TIME '18:00:00 MST7MDT') I get the following error: invalid input syntax for type time: "08:00:00 MST7MDT" It works if I use 'MST' instead of 'MST7MDT', but I need it to be aware of

UTC Time, Timezones, Daylight Savings, and Daylight Savings switchover dates

假如想象 提交于 2019-12-08 10:03:35
问题 I'm building an application which will be able to send emails at any specific local time to any place in the world. For example, my daily schedule (localtime): 8:00 AM - Send email to John in Toronto, Canada 9:15 AM Western Standard Time (Australia) - Send email to Bob in Perth, Australia 10:12 PM - Send email to Anas in Rabat, Morocco I want to be able to execute this code on and Amazon EC2 server in a single location (e.g. São Paulo, Brasil). I also know that Toronto is in Eastern Standard

Why does pytz correctly adjust time & offset when crossing TZ & DST boundaries but not the TZ name?

走远了吗. 提交于 2019-12-08 02:20:06
问题 I have reviewed several pytz -related questions here, but none seems to address the exact problem I'm seeing. Following the pytz documentation, here's a loop to print the current time in multiple time zones, including time zone offset, time zone name, and whether the datetime object thinks it's DST. nowDT = datetime.datetime.now() chicagoTz = pytz.timezone('America/Chicago') chicagoDT = chicagoTz.normalize(chicagoTz.localize(nowDT)) sys.stdout.write( "%-10s %-35s %s\n" % ('Chicago', chicagoDT

Customizable DST Rules

蹲街弑〆低调 提交于 2019-12-08 02:04:24
问题 What's the task? By project specification i need to calculate DST rules for specific time zone offsets. Rules cannot be applied via standard instruments like date_default_timezone_set() because we can't rely on software configuration and can't get it updated if some DST rules will be changed. What i have? In situations when DST switch date is on the last week and the switch day of the last week is on the next month i need to decrement the number of the last week. For now i have only one ugly