Questions tagged [dst]

DST is the tag for Daylight Saving Time issues. DST, also known as summer time, starts when a time zone shifts its clocks forward (in the spring), and ends when the clocks shift back (in the fall).

DST is the tag for Daylight Saving Time issues. Daylight Saving Time is the period when a time zone shifts its time forward in the spring (usually by one hour) and then shifts back in the fall. This creates many programming issues dealing with the lost hour in the spring, and the extra hour in the fall.

Daylight saving time is sometimes called "Summer Time", as time is changed during the summer as compared to the rest of the year. Keep in mind that the northern and southern hemispheres observe summer at different times.

Also, sometimes the term is erroneously called "daylight savings time", or just "daylight savings". Neither term is correct. There is no "s". Another erroneous term is "Day Light Savings" (or "DLS"), which is incorrect because "daylight" is a single word. All of these terms should be avoided.

To illustrate the effects of DST, consider the following graphs. These represent the daylight saving time transitions for the US Pacific time zone.

                Spring Forward DST Transition

                Fall Back DST Transition

While other time zones may transition at different points in time, the behaviors are similar. There is a "gap" of missing local time during the "spring forward" transition, and there is an "overlap" of ambiguous local time during the "fall back" transition.

These graphs also demonstrate the mathematical behaviors of the transitions:

  • Conversion from UTC to Local Time is a function over the range of all time that the local time zone was in existence.

    • However, it may not be a continuous function, due to the transitional adjustments that are made for daylight saving time.

    • Keep in mind that the local time zone was probably not always well defined, or it may have been defined using some earlier calendar system.

  • Conversion from Local Time to UTC is not a pure function because:

    • There may be a discontinuity for the "spring forward" transition, so a local time in this range would be undefined.

    • There may be a range where it is not a function at all, because there is more than one possible outcome for a single input, which occures during the "fall-back" transition.

    • This can lead to problems because some people think that you can always convert in either direction, which is false for any time zone that observes daylight saving time.

Also keep in mind that in the Northern Hemisphere, the "spring forward" transition occurs early in the year and the "fall back" transition occurs late in the year. However, in the Southern Hemisphere the seasons are inverted, so the "fall back" transition typically comes early in the year, while the "spring forward" transition comes late in the year.

Also keep in mind:

  • Not every time zone of the world uses daylight saving time. In fact, the majority do not. See this Wikipedia Article for details.

  • Of those that uses it, each time zone decides how DST applies. Different countries will start and end daylight time at different dates.

  • Not every time zone transitions by one hour. For example, the Australia/Lord_Howe time zone only shifts by 30 minutes.

  • Governments of the world often make changes to how they want to follow DST. You cannot assume that the current rules have always applied in the past or always will apply in the future.

  • DST transition days will have less or more actual time than 24 hours. In most cases, spring-forward days will have 23 hours, and fall-back days will have 25.

  • There are not always exactly a single pair of DST transitions in a given year. Other real-world cases include:

    • One spring transition : This occurs when a time zone decides to stay on "permanent summer time". For example, in 2015 the Turks and Caicos Islands sprung forward in March and stayed there. This is often modeled as a change in base-offset from UTC-5 to UTC-4.

    • One fall transition : This occurs when a time zone that was on "permanent summer time" switches back to standard time. This occurred across Russia in 2014.

    • Two transitions : This is the common case.

    • Three transitions : This is much rarer, but occurred in 2011 in Samoa. The first two transitions were for DST, and the third occurred when 24 hours were skipped to change the island's base-offset from UTC-10 to UTC+14.

    • Four transitions : This occurs when a country that observes DST decides to suspend it temporarily. This has been done in both Egypt and Morocco for the observation of Ramadan.

1319 questions
20
votes
1 answer

pytz.astimezone not accounting for daylight savings?

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,…
dholstius
  • 1,007
  • 1
  • 7
  • 16
20
votes
2 answers

Get Daylight Saving Transition Dates For Time Zones in Java

I'd like to know the simplest way, in Java, to get a list of dates in the future where daylight savings time will change. One rather inellegant way to do this would be to simply iterate over a bunch of years' worth of days, testing them against…
morgancodes
  • 25,055
  • 38
  • 135
  • 187
19
votes
3 answers

Resolving AmbiguousTimeError from Django's make_aware

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…
Zags
  • 37,389
  • 14
  • 105
  • 140
18
votes
2 answers

DateTime - Strange daylight savings behaviour

My local timezone is (UTC+10:00) Canberra, Melbourne, Sydney Sat 31-Mar-2012 15:59 UTC = Sun 01-Apr-2012 02:59 +11:00 Sat 31-Mar-2012 16:00 UTC = Sun 01-Apr-2012 02:00 +10:00 Daylight savings finishes at 3 AM first Sunday in April and the clock wind…
Robert Slaney
  • 3,712
  • 1
  • 21
  • 25
18
votes
1 answer

Does ConvertTimeFromUtc() and ToUniversalTime() handle DST?

If daylight saving time is in effect, and a date object has been saved into the database (UTC format) which you retrieve to show it in the view (for example the view in asp.net-mvc). And you do that by using this method: public static DateTime…
Quoter
  • 4,236
  • 13
  • 47
  • 69
16
votes
1 answer

How to determine when DST starts or ends in a specific location in Python?

I'm looking for a method of determining when DST starts or ends for a given timezone in a Python script I'm working on. I know pytz can convert the UTC dates I'm working into localtime, and will take DST into account, however for this particular…
Smingos
  • 280
  • 1
  • 3
  • 9
16
votes
2 answers

c# daylight savings duplicate hour convert to UTC

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…
amackay11
  • 719
  • 1
  • 10
  • 17
16
votes
1 answer

Mysql converting TIMESTAMP to INTEGER - timezones

I need to convert some TIMESTAMP fields to INT in our MySQL (InnoDB) DB. I realize that converting a TIMESTAMP to INT is unusual, but we still need to do it :) It seems straight-forward enough to do, but there are some timezone and daylight saving…
Halfgaar
  • 732
  • 2
  • 7
  • 32
15
votes
3 answers

GregorianCalendar DST problems

If I take the time at the end of the autumn day light time shift (2014-10-26 02:00:00 CET in Denmark) and subtract one hour (so I would expect to go back to 02:00 CEST) and then set the minutes to zero, I get some strange results: Calendar cal =…
Rasmus Faber
  • 48,631
  • 24
  • 141
  • 189
15
votes
5 answers

Java: Calculating time zone difference

How do I get the time difference from GMT for a specific date and time zone in Java? Determining whether a specific time zone is in DST is quite straight-forward: boolean isIsraelInDST = TimeZone.getTimeZone("Israel").inDaylightTime(new…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
15
votes
4 answers

Confusing behaviour of mktime() function : increasing tm_hour count by one

I am executing below code. int main() { struct tm storage={0,0,0,0,0,0,0,0,0}; char *p = NULL; p = (char *)strptime("2012-08-25 12:23:12","%Y-%m-%d %H:%M:%S",&storage); char buff[1024]={0}; strftime(buff,1024,"%Y-%m-%d %H:%M:%S",&storage); cout…
Dhiraj Neve
  • 235
  • 2
  • 4
  • 11
15
votes
4 answers

Does TimeZoneInfo take DST into consideration?

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 =…
Aabela
  • 1,408
  • 5
  • 19
  • 28
14
votes
3 answers

How to add weekly timedeltas with regards to daylight saving timezones

I want to add or subtract weeks (or days or month or years) to localized datetime objects. The problem is, that the naive approach will result in 1 hour shifts due to daylight saving timezones. 2014-03-27 12:00 is right before the switch from winter…
davidn
  • 812
  • 8
  • 13
14
votes
4 answers

Detect daylight saving time in bash

I want to detect if I'm in winter or summer time. My current approach is: if date +%Z | grep -e CET -e EST; then # I'm in winter time else # I'm in summer time fi which have obvious drawback as you have to know all the timezone names.
jhutar
  • 1,369
  • 2
  • 17
  • 32
14
votes
5 answers

How to tell if a timezone observes daylight saving at any time of the year?

In PHP, you can tell if a given date is during the Daylight Savings Time period by using something like this: $isDST = date("I", $myDate); // 1 or 0 The problem is that this only tells you whether that one point in time is in DST. Is there a…
nickf
  • 537,072
  • 198
  • 649
  • 721
1 2
3
87 88