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. Date Time Picker standard time to daylight savings time problem

Date Time Picker standard time to daylight savings time problem

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
11 Posts 4 Posters 4 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 Member_15772061

    Hi everyone, I created a report program where a from/to date range is selected to display that range of reports to a listview control. The problem: If that range crosses a shift from standard time to DST you lose a day. Example: Mar 11 2023 to Mar 12 2023 time period is 0 days and only Mar 11 2023 is shown even though the range is 11 to 12th. Does anyone know what or if there is a fix for this? This is my first post so please advise if I am not using this correctly. Thank you, Steve

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

    Are there any reports in the data store dated Mar 12th?

    "One man's wage rise is another man's price increase." - Harold Wilson

    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

    "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

    M 1 Reply Last reply
    0
    • M Member_15772061

      Hi everyone, I created a report program where a from/to date range is selected to display that range of reports to a listview control. The problem: If that range crosses a shift from standard time to DST you lose a day. Example: Mar 11 2023 to Mar 12 2023 time period is 0 days and only Mar 11 2023 is shown even though the range is 11 to 12th. Does anyone know what or if there is a fix for this? This is my first post so please advise if I am not using this correctly. Thank you, Steve

      Mircea NeacsuM Offline
      Mircea NeacsuM Offline
      Mircea Neacsu
      wrote on last edited by
      #3

      You provide to little information to be able to help. What data store are you using? How are the dates stored? In what time units you calculate (days, hours, seconds)? For instance from Mar 11, 2023 03:00:00 to Mar 12, 2023 03:00:00 there are only 23 hours so your system might say it's less than a day. Having worked for a long time with time, my advice is to always use UTC. It's the only (almost) uniform time scale and computations to and from local time can be handled relatively easy.

      Mircea

      L M 2 Replies Last reply
      0
      • Mircea NeacsuM Mircea Neacsu

        You provide to little information to be able to help. What data store are you using? How are the dates stored? In what time units you calculate (days, hours, seconds)? For instance from Mar 11, 2023 03:00:00 to Mar 12, 2023 03:00:00 there are only 23 hours so your system might say it's less than a day. Having worked for a long time with time, my advice is to always use UTC. It's the only (almost) uniform time scale and computations to and from local time can be handled relatively easy.

        Mircea

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #4

        Mircea Neacsu wrote:

        always use UTC

        When I suggested that to the designers and team leaders driving the last commercial project that I worked on, the answer was, "No, we need to keep track of transactions by local time". :rolleyes: Fortunately the project was canned not long afterwards.

        Mircea NeacsuM 1 Reply Last reply
        0
        • L Lost User

          Mircea Neacsu wrote:

          always use UTC

          When I suggested that to the designers and team leaders driving the last commercial project that I worked on, the answer was, "No, we need to keep track of transactions by local time". :rolleyes: Fortunately the project was canned not long afterwards.

          Mircea NeacsuM Offline
          Mircea NeacsuM Offline
          Mircea Neacsu
          wrote on last edited by
          #5

          Richard MacCutchan wrote:

          we need to keep track of transactions by local time

          Not surprised. I've seen the same attitude by one of the habituals in the lounge. People don't understand that local time is mostly an expression of political will rather than a time scale.Even with UTC some forget about the occasional leap second but at least Earth is not playing any political games. Best put by Dr Who: Big ball of wibbly wobbly... time-y wimey... stuff.[^]

          Mircea

          L 1 Reply Last reply
          0
          • D David Crow

            Are there any reports in the data store dated Mar 12th?

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

            M Offline
            M Offline
            Member_15772061
            wrote on last edited by
            #6

            Apologies yes! Mar_11_2023_hst.txt and Mar_12_hst.txt I saw someone else had commented that maybe my time in hours is not 24 since you lose the 2am hour from daylight savings time. I think that may be the problem. i will post when i get a chance to look at it. Thank you.

            1 Reply Last reply
            0
            • Mircea NeacsuM Mircea Neacsu

              You provide to little information to be able to help. What data store are you using? How are the dates stored? In what time units you calculate (days, hours, seconds)? For instance from Mar 11, 2023 03:00:00 to Mar 12, 2023 03:00:00 there are only 23 hours so your system might say it's less than a day. Having worked for a long time with time, my advice is to always use UTC. It's the only (almost) uniform time scale and computations to and from local time can be handled relatively easy.

              Mircea

              M Offline
              M Offline
              Member_15772061
              wrote on last edited by
              #7

              Hi Mircea, I think you might be onto something here! I will check my code and probably even use UTC and end this little problem. Thank you.

              L 1 Reply Last reply
              0
              • Mircea NeacsuM Mircea Neacsu

                Richard MacCutchan wrote:

                we need to keep track of transactions by local time

                Not surprised. I've seen the same attitude by one of the habituals in the lounge. People don't understand that local time is mostly an expression of political will rather than a time scale.Even with UTC some forget about the occasional leap second but at least Earth is not playing any political games. Best put by Dr Who: Big ball of wibbly wobbly... time-y wimey... stuff.[^]

                Mircea

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #8

                That I can understand. :-D

                1 Reply Last reply
                0
                • M Member_15772061

                  Hi Mircea, I think you might be onto something here! I will check my code and probably even use UTC and end this little problem. Thank you.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #9

                  As Mircea says, "always use UTC". The only time you need to convert it to local time is when you want to display it to one of those insignificant, and simple, blobs of protoplasm that inhabit the earth.

                  Mircea NeacsuM 1 Reply Last reply
                  0
                  • L Lost User

                    As Mircea says, "always use UTC". The only time you need to convert it to local time is when you want to display it to one of those insignificant, and simple, blobs of protoplasm that inhabit the earth.

                    Mircea NeacsuM Offline
                    Mircea NeacsuM Offline
                    Mircea Neacsu
                    wrote on last edited by
                    #10

                    Looks like someone here doesn't like UTC and down-voted both my answer and yours. Oh well, can't please everyone! :laugh:

                    Mircea

                    L 1 Reply Last reply
                    0
                    • Mircea NeacsuM Mircea Neacsu

                      Looks like someone here doesn't like UTC and down-voted both my answer and yours. Oh well, can't please everyone! :laugh:

                      Mircea

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #11

                      I'm more interested in helping people than pleasing them. Probably one of the reasons I got in trouble at work.

                      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