Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Summer & Winter time

Summer & Winter time

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Martijn van Kleef
    wrote on last edited by
    #1

    How do I check whether it's summertime or wintertime for a given date x? How do I determine when switches between summertime and wintertime occur?

    M A J D M 5 Replies Last reply
    0
    • M Martijn van Kleef

      How do I check whether it's summertime or wintertime for a given date x? How do I determine when switches between summertime and wintertime occur?

      M Offline
      M Offline
      Martijn van Kleef
      wrote on last edited by
      #2

      Well I still don't know how to easily check exactly when a switch between winter and summer time would occur, but I did figure out how to determine which one of the 2 is in effect at any given date x. The Daylight Savings Time flag indicates whether the current time for your locale is summertime (1) or wintertime (0), example: time_t t1; // Get current time (our given date x) time(&t1); // Adjust for locale struct tm * t2 = localtime(&t1); printf("DST Now:%d\n", t2->tm_isdst); // Substract 90 days t1 -= 7776000; // Adjust for locale t2 = localtime(&t1); printf("DST Then:%d\n", t2->tm_isdst); Still trying to find out exactly when shifts occur though.

      1 Reply Last reply
      0
      • M Martijn van Kleef

        How do I check whether it's summertime or wintertime for a given date x? How do I determine when switches between summertime and wintertime occur?

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        The switch from summer to winter happens on the last Sunday of October at 2:am I think. The switch from winter to summer on the last Sunday of March again at 2am Hope this helps you.. Greets, Davy

        J H 2 Replies Last reply
        0
        • M Martijn van Kleef

          How do I check whether it's summertime or wintertime for a given date x? How do I determine when switches between summertime and wintertime occur?

          J Offline
          J Offline
          jan larsen
          wrote on last edited by
          #4

          Look up GetTimeZoneInformation(), it fills a TIME_ZONE_INFORMATION structure where you can get the SYSTEMTIME of the daylight date and the standard date. [edit]:doh: forgot to tell you that the return value actually tells you if it is daylight saving time or not.[/edit] "After all it's just text at the end of the day. - Colin Davies "For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus

          1 Reply Last reply
          0
          • A Anonymous

            The switch from summer to winter happens on the last Sunday of October at 2:am I think. The switch from winter to summer on the last Sunday of March again at 2am Hope this helps you.. Greets, Davy

            J Offline
            J Offline
            jan larsen
            wrote on last edited by
            #5

            Anonymous wrote: The switch from summer to winter happens on the last Sunday of October at 2:am I think. The switch from winter to summer on the last Sunday of March again at 2am :-D Could be that a more i18n safe procedure is called for. "After all it's just text at the end of the day. - Colin Davies "For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus

            1 Reply Last reply
            0
            • M Martijn van Kleef

              How do I check whether it's summertime or wintertime for a given date x? How do I determine when switches between summertime and wintertime occur?

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              For this you'll need to read up on the winter and summer solstice: http://scienceworld.wolfram.com/astronomy/WinterSolstice.html http://scienceworld.wolfram.com/astronomy/SummerSolstice.html


              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              1 Reply Last reply
              0
              • A Anonymous

                The switch from summer to winter happens on the last Sunday of October at 2:am I think. The switch from winter to summer on the last Sunday of March again at 2am Hope this helps you.. Greets, Davy

                H Offline
                H Offline
                Henry miller
                wrote on last edited by
                #7

                Only in the parts of the US that bother with the stupid thing. Several US states (or parts of states in at least one case) do not bother with it at all. Many countries around the world have their own date, which is not the same as the US date. Better look for a different way to figure it out. Best is to get everyone off the stupid idea. I have yet to hear a good argument for daylight savings time. Thats a different rant though, so I'll head over to soapbox someday and give it to those interested.

                1 Reply Last reply
                0
                • M Martijn van Kleef

                  How do I check whether it's summertime or wintertime for a given date x? How do I determine when switches between summertime and wintertime occur?

                  M Offline
                  M Offline
                  Michael Dunn
                  wrote on last edited by
                  #8

                  If you actually mean what the season is, not just the daylight saving time flag, there isn't a single algorithm for it since different countries define the seasons differently. Ie if you try to tell someone in Australia that December 25 is in the winter, you'll get weird looks. Also, some countries like the US define the seasons based on the solstices and equinoxes, while others change seasons on the first of the month every 3 months. --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups