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
8
votes
4 answers

Get Daylight Saving Transition Dates For Time Zones in C

In C, is there a simple, cross-platform way of retrieving the dates that a given timezone begins and ends daylight saving? I already have timezone offset information and whether or not daylight savings is currently being observed, but I really need…
user82116
  • 418
  • 5
  • 12
8
votes
3 answers

Get timezone offset for a given location

Is it possible in PHP to get the timezone offset for a given location? E.g. when given the location "Sydney/Australia" to get the timezone offset as "+1100". Bonus would be for this function the keep daylight savings in mind (i.e. it's aware of…
Luke
  • 20,878
  • 35
  • 119
  • 178
8
votes
3 answers

Dealing with Eastern Standard Time (EST) and Eastern Daylight Savings (EDT) in R

I have a series of datasets from a water quality continuous monitoring probe with the Date and Time set in Eastern Standard Time (EST) so there is no correction of Daylight Savings Time (EDT). In R, the fields are recognized as factors when…
Paul Julian
  • 245
  • 1
  • 2
  • 7
8
votes
1 answer

How to make Time::Piece respect DST when converting localtime to UTC?

I want to convert a timestamp from localtime to GMT. I have legacy code that does this "manually" with Time::Local::timelocal() and gmtime. It works, but I don't like it and wanted to use Time::Piece instead. I used this answer to do so (albeit they…
PerlDuck
  • 5,610
  • 3
  • 20
  • 39
8
votes
1 answer

Windows 7 daylight savings bug?

I am trying to determine exactly when a daylight savings transition occurs in a Perl script using Perl's localtime function and printing the time zone using strftime. The strange thing is this seems to work fine for this year and other more recent…
tjwrona1992
  • 8,614
  • 8
  • 35
  • 98
8
votes
1 answer

How to detect Daylight Saving Time transition in android

I have an android app that has a service witch fires an alert based on some time calculation. The problem is when the timezone changes (i.e.: For a user who's located France and goes from UTC+1 to UTC+2). The application is not notified about this…
Soufiane ROCHDI
  • 1,543
  • 17
  • 24
8
votes
1 answer

In Rails, why is 1.year.from_now not the same as 1.year.to_i.seconds.from_now?

Can I make Rails apply the same logic to my calculation in seconds as it does to my calculation in years? puts "#{1.year.from_now} | #{1.year.to_i.seconds.from_now}" 2017-03-23 18:48:06 UTC | 2017-03-24 00:48:06 UTC I don’t understand where the…
djb
  • 5,591
  • 5
  • 41
  • 47
8
votes
3 answers

Convert somebody's local time to the UTC time

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…
Michel
  • 23,085
  • 46
  • 152
  • 242
8
votes
3 answers

Offset time for DST in one specific timezone using JavaScript

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…
Shannon
  • 91
  • 1
  • 3
8
votes
1 answer

Daylight saving hours in Golang

I have been designing a UI for a scheduling interface, where a user can set timers a number of hours into the future. I want to be able to handle daylight saving if possible, I thought it would be quite simple. Whilst checking out time.Time in the…
hairy_marmite
  • 129
  • 2
  • 8
8
votes
3 answers

Django DST Time change issue with django datetimefield

I am facing problem in my django app while working with DateTimeField.Its mainly because of DST time changes. I have created an event on 30-oct-2015(DST last week). I created a copy of first event which will be on 06-Nov-2015(Non DST day) I applied…
RMK
  • 1,111
  • 4
  • 14
  • 33
8
votes
5 answers

How to schedule an Oracle dbms_scheduler Job timezone and DST safely

I am trying to setup a DBMS_SCHEDULER Job to run exactly at 1 AM on 1st of January every year on Oracle 11g. How to setup its attributes to be absolutely sure it wont get executed in wrong hour, because of timezone differences nor Daylight Savings…
Javo
  • 435
  • 1
  • 5
  • 16
8
votes
2 answers

Is the value returned by System.currentTimeMillis() affected by Day Light Savings and Leap Second adjustments?

I know that System.currentTimeMillis() gives the time in milliseconds since the epoch and it is sensitive to the wall clock time of the system. I also know that it is not advisable to use System.currentTimeMillis() to calculate elapsed time in a…
Geek
  • 26,489
  • 43
  • 149
  • 227
8
votes
1 answer

moment.js, timezones and daylight savings

I return a list of UTC dates/times from a .Net service, formatted like so: "2013-07-09 19:48:07 +00:00". On the client, I convert each of these string values into a corresponding UTC-based moment, like so var fooUtc = new…
Joshua Barker
  • 987
  • 2
  • 11
  • 23
8
votes
3 answers

Why doesn't .NET convert the time correctly?

In the year 2013, the United Kingdom won't start daylight savings time until March 31st. Still, TimeZoneInfo.ConvertTimeToUtc subtracts one hour when I try to convert a given time to UTC time. Why is this? Do I need to tell this method that daylight…
Jim G.
  • 15,141
  • 22
  • 103
  • 166