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. The Lounge
  3. It's about TIME for a programming question

It's about TIME for a programming question

Scheduled Pinned Locked Moved The Lounge
helpquestionlearningpythoncom
47 Posts 27 Posters 2 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 Marc Clifton

    The problem with time is that it is (of course) different depending on your time zone and daylight savings time for your region. Scenario 1: Let's say I make a blog entry at 8 AM EST, then I get on an airplane and fly to CA and set my computer to PST. When I look at my blog entry, it probably says that I made the post at 5 AM, but in my thinking, my frame of reference is still "when did I make that post (when I was in NY)?" Scenario 2: I make a blog entry at 8 AM EST, and you, living in CA, notice my blog entry, which has a time of 5 AM (because you're in PST.) That makes sense to you, in your reference frame, because you know you're 3 hours earlier. Scenario 3: I run a company that has ATM's (disclaimer: this is a good example, irrelevant to the fact that write software for ATM's, I'm not asking you to solve programming problem in that regard) in local gas stations all over the country. A customer in NY (UTC-5 at some points of the year) calls and says the ATM didn't dispense cash or a receipt! The help desk asks when they did the transaction, and they say, around 8 AM because that's the time in NY. The customer service is in CA (UTC-8 at the moment, we'll customer service in India for this scenario), so what time do they search for? Do they need to ask "where were you?" so they know the time zone and mentally subtract off 3 hours (maybe dealing a 1 AM NY transaction on 1/1/2016 now being seen in CA as 12/31/2015 10 PM????) So the question becomes, what does the user need to see, and what do they expect to see? When (harhar) does it make more sense to store date/time in the true local time, including timezone (either "PST" style notation, or "UTC-8" notation, for example, keeping in mind that not everyone knows what "UTC" is or even timezone designations like EST, MST, PST, etc. When does it make sense to convert to local time? Should both "my local time" and "transaction local time" be available for displaying/searching? Am I missing something obvious? Have you had to deal with this issue? And I haven't even touched the nightmare of daylight savings time. Marc

    Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventual

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

    Marc Clifton wrote:

    Have you had to deal with this issue?

    Yes, and it drove me to distraction since no one seemed to understand the problem. Rather than storing the time as local we were saving it as UTC but with an added field that was the offset to local. It never worked satisfactorily, and the project got canned.

    M 1 Reply Last reply
    0
    • B Basildane

      Time is an illusion. Lunch time doubly so. However, you always store your times in UTC. Convert to local time for the observer, on-the-fly. If I am reading this in CA, then show that time zone (with the -PST). If I am in Washington, show -EST or -EDT).... Or did I misunderstand the question?

      N Offline
      N Offline
      Nelek
      wrote on last edited by
      #12

      Basildane wrote:

      Convert to local time for the observer, on-the-fly.

      A bit difficult for the szenario of calling the hotline.

      M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

      1 Reply Last reply
      0
      • N Nelek

        and how do you know which one is on the szenario of the phone call to the hotline?

        M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

        D Offline
        D Offline
        Duncan Edwards Jones
        wrote on last edited by
        #13

        When you enter a query (we don't have telephones in this business) the data are returned in UTC but displayed in local. In the example, yes we would need to know where the ATM was located.

        1 Reply Last reply
        0
        • M Marc Clifton

          The problem with time is that it is (of course) different depending on your time zone and daylight savings time for your region. Scenario 1: Let's say I make a blog entry at 8 AM EST, then I get on an airplane and fly to CA and set my computer to PST. When I look at my blog entry, it probably says that I made the post at 5 AM, but in my thinking, my frame of reference is still "when did I make that post (when I was in NY)?" Scenario 2: I make a blog entry at 8 AM EST, and you, living in CA, notice my blog entry, which has a time of 5 AM (because you're in PST.) That makes sense to you, in your reference frame, because you know you're 3 hours earlier. Scenario 3: I run a company that has ATM's (disclaimer: this is a good example, irrelevant to the fact that write software for ATM's, I'm not asking you to solve programming problem in that regard) in local gas stations all over the country. A customer in NY (UTC-5 at some points of the year) calls and says the ATM didn't dispense cash or a receipt! The help desk asks when they did the transaction, and they say, around 8 AM because that's the time in NY. The customer service is in CA (UTC-8 at the moment, we'll customer service in India for this scenario), so what time do they search for? Do they need to ask "where were you?" so they know the time zone and mentally subtract off 3 hours (maybe dealing a 1 AM NY transaction on 1/1/2016 now being seen in CA as 12/31/2015 10 PM????) So the question becomes, what does the user need to see, and what do they expect to see? When (harhar) does it make more sense to store date/time in the true local time, including timezone (either "PST" style notation, or "UTC-8" notation, for example, keeping in mind that not everyone knows what "UTC" is or even timezone designations like EST, MST, PST, etc. When does it make sense to convert to local time? Should both "my local time" and "transaction local time" be available for displaying/searching? Am I missing something obvious? Have you had to deal with this issue? And I haven't even touched the nightmare of daylight savings time. Marc

          Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventual

          K Offline
          K Offline
          kmoorevs
          wrote on last edited by
          #14

          My last 'new' project was/is a cloud based timeclock. I'm probably doing it all wrong, but found it easier to store converted local times and straight utc times for everything. Of course, it all depends on the type of application and whether or not you have users in multiple time zones.

          "Go forth into the source" - Neal Morse

          M 1 Reply Last reply
          0
          • M Marc Clifton

            The problem with time is that it is (of course) different depending on your time zone and daylight savings time for your region. Scenario 1: Let's say I make a blog entry at 8 AM EST, then I get on an airplane and fly to CA and set my computer to PST. When I look at my blog entry, it probably says that I made the post at 5 AM, but in my thinking, my frame of reference is still "when did I make that post (when I was in NY)?" Scenario 2: I make a blog entry at 8 AM EST, and you, living in CA, notice my blog entry, which has a time of 5 AM (because you're in PST.) That makes sense to you, in your reference frame, because you know you're 3 hours earlier. Scenario 3: I run a company that has ATM's (disclaimer: this is a good example, irrelevant to the fact that write software for ATM's, I'm not asking you to solve programming problem in that regard) in local gas stations all over the country. A customer in NY (UTC-5 at some points of the year) calls and says the ATM didn't dispense cash or a receipt! The help desk asks when they did the transaction, and they say, around 8 AM because that's the time in NY. The customer service is in CA (UTC-8 at the moment, we'll customer service in India for this scenario), so what time do they search for? Do they need to ask "where were you?" so they know the time zone and mentally subtract off 3 hours (maybe dealing a 1 AM NY transaction on 1/1/2016 now being seen in CA as 12/31/2015 10 PM????) So the question becomes, what does the user need to see, and what do they expect to see? When (harhar) does it make more sense to store date/time in the true local time, including timezone (either "PST" style notation, or "UTC-8" notation, for example, keeping in mind that not everyone knows what "UTC" is or even timezone designations like EST, MST, PST, etc. When does it make sense to convert to local time? Should both "my local time" and "transaction local time" be available for displaying/searching? Am I missing something obvious? Have you had to deal with this issue? And I haven't even touched the nightmare of daylight savings time. Marc

            Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventual

            R Offline
            R Offline
            Rob Philpott
            wrote on last edited by
            #15

            I think dealing with time in code is one of the hardest things I've worked on, and I still don't know what the best solution is. I've done it a lot over the years. To avoid daylight saving issues, I tend to store everything in UTC (or GMT to give it its correct title!), then do local conversion. If everything feeds in UTC then at least the same DateTime refers to the same moment wherever you are. But if you have any scheduled tasks, these will need to be rescheduled twice a year as you enter and exit daylight saving. The main problem is that other people don't (use UTC), DateTime.Now is too easy, and this humble type's 'kind' only tells you whether it is UTC/local etc, but not where local is. By the time its gone in and out of SQL server it might have been the time on the moon for all its worth. Then there's UTC to local time and back conversion which is not that easy. Hmmmmm, I don't know where I'm going with this - not a clue. Horrible. But good luck..!

            Regards, Rob Philpott.

            M 1 Reply Last reply
            0
            • M Marc Clifton

              The problem with time is that it is (of course) different depending on your time zone and daylight savings time for your region. Scenario 1: Let's say I make a blog entry at 8 AM EST, then I get on an airplane and fly to CA and set my computer to PST. When I look at my blog entry, it probably says that I made the post at 5 AM, but in my thinking, my frame of reference is still "when did I make that post (when I was in NY)?" Scenario 2: I make a blog entry at 8 AM EST, and you, living in CA, notice my blog entry, which has a time of 5 AM (because you're in PST.) That makes sense to you, in your reference frame, because you know you're 3 hours earlier. Scenario 3: I run a company that has ATM's (disclaimer: this is a good example, irrelevant to the fact that write software for ATM's, I'm not asking you to solve programming problem in that regard) in local gas stations all over the country. A customer in NY (UTC-5 at some points of the year) calls and says the ATM didn't dispense cash or a receipt! The help desk asks when they did the transaction, and they say, around 8 AM because that's the time in NY. The customer service is in CA (UTC-8 at the moment, we'll customer service in India for this scenario), so what time do they search for? Do they need to ask "where were you?" so they know the time zone and mentally subtract off 3 hours (maybe dealing a 1 AM NY transaction on 1/1/2016 now being seen in CA as 12/31/2015 10 PM????) So the question becomes, what does the user need to see, and what do they expect to see? When (harhar) does it make more sense to store date/time in the true local time, including timezone (either "PST" style notation, or "UTC-8" notation, for example, keeping in mind that not everyone knows what "UTC" is or even timezone designations like EST, MST, PST, etc. When does it make sense to convert to local time? Should both "my local time" and "transaction local time" be available for displaying/searching? Am I missing something obvious? Have you had to deal with this issue? And I haven't even touched the nightmare of daylight savings time. Marc

              Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventual

              C Offline
              C Offline
              Clifford Nelson
              wrote on last edited by
              #16

              Finishing my contract with Clarity Medical Systems and had an interview for 4:00 PM. The person I was interviewing with was in MST while I am in PST. Well the person scheduling the Interview converted for me, but unfortunately the that was giving the interview converted again, and so did not get a call until 5:00 PM. In China they only have one time zone. Somebody has recommended going to two in the US. Think this is a good idea. The Eastern Time Zone has been pushed so far West that it is practically to the Mississippi. Why not just take it all the way to the Mississippi, and maybe a little further. The Central Time Zone is huge despite encroachment by the Eastern Time zone, and the Pacific Time Zone covers all of Nevada to the border of Alaska. Two time zones sounds better than the 4 we have.

              M 1 Reply Last reply
              0
              • H HobbyProggy

                Marc Clifton wrote:

                not everyone knows what "UTC" is or even

                That was "unbelievable tortoise crash" right?

                Rules for the FOSW ![^]

                if(this.signature != "")
                {
                MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
                }
                else
                {
                MessageBox.Show("404-Signature not found");
                }

                M Offline
                M Offline
                Marc Clifton
                wrote on last edited by
                #17

                HobbyProggy wrote:

                That was "unbelievable tortoise crash" right?

                When the tortoise[^] crashes, the world comes to an end. :~ Marc

                Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                B 1 Reply Last reply
                0
                • D Duncan Edwards Jones

                  In my business we never store local time - conversion to/from that is always a UI or interface concern.

                  M Offline
                  M Offline
                  Marc Clifton
                  wrote on last edited by
                  #18

                  Duncan Edwards Jones wrote:

                  In my business we never store local time - conversion to/from that is always a UI or interface concern.

                  Yes, storing the UTC time is definitely the starting point, and I agree, the conversion to/from is a UI concern, but for it to do it's job correctly for the requirements, it may need additional information, at least, that's my thinking. Marc

                  Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                  D 1 Reply Last reply
                  0
                  • M Marc Clifton

                    The problem with time is that it is (of course) different depending on your time zone and daylight savings time for your region. Scenario 1: Let's say I make a blog entry at 8 AM EST, then I get on an airplane and fly to CA and set my computer to PST. When I look at my blog entry, it probably says that I made the post at 5 AM, but in my thinking, my frame of reference is still "when did I make that post (when I was in NY)?" Scenario 2: I make a blog entry at 8 AM EST, and you, living in CA, notice my blog entry, which has a time of 5 AM (because you're in PST.) That makes sense to you, in your reference frame, because you know you're 3 hours earlier. Scenario 3: I run a company that has ATM's (disclaimer: this is a good example, irrelevant to the fact that write software for ATM's, I'm not asking you to solve programming problem in that regard) in local gas stations all over the country. A customer in NY (UTC-5 at some points of the year) calls and says the ATM didn't dispense cash or a receipt! The help desk asks when they did the transaction, and they say, around 8 AM because that's the time in NY. The customer service is in CA (UTC-8 at the moment, we'll customer service in India for this scenario), so what time do they search for? Do they need to ask "where were you?" so they know the time zone and mentally subtract off 3 hours (maybe dealing a 1 AM NY transaction on 1/1/2016 now being seen in CA as 12/31/2015 10 PM????) So the question becomes, what does the user need to see, and what do they expect to see? When (harhar) does it make more sense to store date/time in the true local time, including timezone (either "PST" style notation, or "UTC-8" notation, for example, keeping in mind that not everyone knows what "UTC" is or even timezone designations like EST, MST, PST, etc. When does it make sense to convert to local time? Should both "my local time" and "transaction local time" be available for displaying/searching? Am I missing something obvious? Have you had to deal with this issue? And I haven't even touched the nightmare of daylight savings time. Marc

                    Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventual

                    W Offline
                    W Offline
                    WiganLatics
                    wrote on last edited by
                    #19

                    In my experience when you call up to say the ATM didn't dispense cash, they'll ask you which ATM. So just use the local time of the ATM.

                    M 1 Reply Last reply
                    0
                    • B Basildane

                      Time is an illusion. Lunch time doubly so. However, you always store your times in UTC. Convert to local time for the observer, on-the-fly. If I am reading this in CA, then show that time zone (with the -PST). If I am in Washington, show -EST or -EDT).... Or did I misunderstand the question?

                      M Offline
                      M Offline
                      Marc Clifton
                      wrote on last edited by
                      #20

                      Basildane wrote:

                      However, you always store your times in UTC. Convert to local time for the observer, on-the-fly.

                      Yup.

                      Basildane wrote:

                      Or did I misunderstand the question?

                      Except the time displayed may need to be relative to where/when the transaction took place, rather than where the viewer is. Marc

                      Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                      J 1 Reply Last reply
                      0
                      • F Foothill

                        Just forget about Earth time and use galactic time. :-\

                        if (Object.DividedByZero == true) { Universe.Implode(); } Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016

                        M Offline
                        M Offline
                        Marc Clifton
                        wrote on last edited by
                        #21

                        Foothill wrote:

                        Just forget about Earth time and use galactic time.

                        That is awesome. I may actually let the user select that as an optional display format! :jig: Marc

                        Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                        1 Reply Last reply
                        0
                        • L Lost User

                          Marc Clifton wrote:

                          Have you had to deal with this issue?

                          Yes, and it drove me to distraction since no one seemed to understand the problem. Rather than storing the time as local we were saving it as UTC but with an added field that was the offset to local. It never worked satisfactorily, and the project got canned.

                          M Offline
                          M Offline
                          Marc Clifton
                          wrote on last edited by
                          #22

                          Richard MacCutchan wrote:

                          It never worked satisfactorily, and the project got canned.

                          :doh: Seems like a problem looking for a solution. Hmmmm... Marc

                          Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                          1 Reply Last reply
                          0
                          • K kmoorevs

                            My last 'new' project was/is a cloud based timeclock. I'm probably doing it all wrong, but found it easier to store converted local times and straight utc times for everything. Of course, it all depends on the type of application and whether or not you have users in multiple time zones.

                            "Go forth into the source" - Neal Morse

                            M Offline
                            M Offline
                            Marc Clifton
                            wrote on last edited by
                            #23

                            kmoorevs wrote:

                            but found it easier to store converted local times and straight utc times for everything.

                            Agreed, that should be the baseline (or is that "basetime"?)

                            kmoorevs wrote:

                            Of course, it all depends on the type of application and whether or not you have users in multiple time zones.

                            Web app, possibly desktop app, but I'm poking at what hopefully can be a general solution "library" / best practices. Marc

                            Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                            1 Reply Last reply
                            0
                            • R Rob Philpott

                              I think dealing with time in code is one of the hardest things I've worked on, and I still don't know what the best solution is. I've done it a lot over the years. To avoid daylight saving issues, I tend to store everything in UTC (or GMT to give it its correct title!), then do local conversion. If everything feeds in UTC then at least the same DateTime refers to the same moment wherever you are. But if you have any scheduled tasks, these will need to be rescheduled twice a year as you enter and exit daylight saving. The main problem is that other people don't (use UTC), DateTime.Now is too easy, and this humble type's 'kind' only tells you whether it is UTC/local etc, but not where local is. By the time its gone in and out of SQL server it might have been the time on the moon for all its worth. Then there's UTC to local time and back conversion which is not that easy. Hmmmmm, I don't know where I'm going with this - not a clue. Horrible. But good luck..!

                              Regards, Rob Philpott.

                              M Offline
                              M Offline
                              Marc Clifton
                              wrote on last edited by
                              #24

                              Rob Philpott wrote:

                              But good luck..!

                              Thanks! :) > But if you have any scheduled tasks, these will need to be rescheduled twice a year as you enter and exit daylight saving. Ugh. Another interesting wrinkle in the fabric of time. Hah! Just came up with the name for a potential article: "A Wrinkle in Time" :) Marc

                              Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                              B 1 Reply Last reply
                              0
                              • C Clifford Nelson

                                Finishing my contract with Clarity Medical Systems and had an interview for 4:00 PM. The person I was interviewing with was in MST while I am in PST. Well the person scheduling the Interview converted for me, but unfortunately the that was giving the interview converted again, and so did not get a call until 5:00 PM. In China they only have one time zone. Somebody has recommended going to two in the US. Think this is a good idea. The Eastern Time Zone has been pushed so far West that it is practically to the Mississippi. Why not just take it all the way to the Mississippi, and maybe a little further. The Central Time Zone is huge despite encroachment by the Eastern Time zone, and the Pacific Time Zone covers all of Nevada to the border of Alaska. Two time zones sounds better than the 4 we have.

                                M Offline
                                M Offline
                                Marc Clifton
                                wrote on last edited by
                                #25

                                Clifford Nelson wrote:

                                Two time zones sounds better than the 4 we have.

                                And the weird holes, particularly states and very local regions that ignore DST. :doh: Marc

                                Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                                C 1 Reply Last reply
                                0
                                • W WiganLatics

                                  In my experience when you call up to say the ATM didn't dispense cash, they'll ask you which ATM. So just use the local time of the ATM.

                                  M Offline
                                  M Offline
                                  Marc Clifton
                                  wrote on last edited by
                                  #26

                                  WiganLatics wrote:

                                  they'll ask you which ATM.

                                  Quite true. But that's assuming the user wasn't drunk, is still by the ATM, and remembers which one they visited. ;) Marc

                                  Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                                  1 Reply Last reply
                                  0
                                  • M Marc Clifton

                                    Clifford Nelson wrote:

                                    Two time zones sounds better than the 4 we have.

                                    And the weird holes, particularly states and very local regions that ignore DST. :doh: Marc

                                    Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                                    C Offline
                                    C Offline
                                    Clifford Nelson
                                    wrote on last edited by
                                    #27

                                    Think the only state that ignores DST, which I think should be eliminated is Arizona. Have lived there. Sort preferred being on Pacific time rather than Mountain time. Then there are all those strange incursions, like Idaho into Oregon and Washington into Idaho.

                                    1 Reply Last reply
                                    0
                                    • M Marc Clifton

                                      Duncan Edwards Jones wrote:

                                      In my business we never store local time - conversion to/from that is always a UI or interface concern.

                                      Yes, storing the UTC time is definitely the starting point, and I agree, the conversion to/from is a UI concern, but for it to do it's job correctly for the requirements, it may need additional information, at least, that's my thinking. Marc

                                      Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                                      D Offline
                                      D Offline
                                      Duncan Edwards Jones
                                      wrote on last edited by
                                      #28

                                      That is definitely needed, yes. Most operating systems and browsers support "locale" information to allow the user interface to discover its location. For phone apps there is the Google maps Timezone API[^] and worst case scenario you can get the client to specify the timezone. If you need to store where the time came from then you could have a "client offset" field that tells you what time the client thought it was when they wrote the record.

                                      1 Reply Last reply
                                      0
                                      • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

                                        I, once, worked on this project - Noda Time | Date and time API for .NET[^] (no warranty and/or guaranty ;) )

                                        Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.

                                        M Offline
                                        M Offline
                                        Marc Clifton
                                        wrote on last edited by
                                        #29

                                        Wow, I just read through the Trivia page. Geez, what a crazy world. I can't imagine the complexity historians have to deal with. Marc

                                        Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                                        1 Reply Last reply
                                        0
                                        • M Marc Clifton

                                          The problem with time is that it is (of course) different depending on your time zone and daylight savings time for your region. Scenario 1: Let's say I make a blog entry at 8 AM EST, then I get on an airplane and fly to CA and set my computer to PST. When I look at my blog entry, it probably says that I made the post at 5 AM, but in my thinking, my frame of reference is still "when did I make that post (when I was in NY)?" Scenario 2: I make a blog entry at 8 AM EST, and you, living in CA, notice my blog entry, which has a time of 5 AM (because you're in PST.) That makes sense to you, in your reference frame, because you know you're 3 hours earlier. Scenario 3: I run a company that has ATM's (disclaimer: this is a good example, irrelevant to the fact that write software for ATM's, I'm not asking you to solve programming problem in that regard) in local gas stations all over the country. A customer in NY (UTC-5 at some points of the year) calls and says the ATM didn't dispense cash or a receipt! The help desk asks when they did the transaction, and they say, around 8 AM because that's the time in NY. The customer service is in CA (UTC-8 at the moment, we'll customer service in India for this scenario), so what time do they search for? Do they need to ask "where were you?" so they know the time zone and mentally subtract off 3 hours (maybe dealing a 1 AM NY transaction on 1/1/2016 now being seen in CA as 12/31/2015 10 PM????) So the question becomes, what does the user need to see, and what do they expect to see? When (harhar) does it make more sense to store date/time in the true local time, including timezone (either "PST" style notation, or "UTC-8" notation, for example, keeping in mind that not everyone knows what "UTC" is or even timezone designations like EST, MST, PST, etc. When does it make sense to convert to local time? Should both "my local time" and "transaction local time" be available for displaying/searching? Am I missing something obvious? Have you had to deal with this issue? And I haven't even touched the nightmare of daylight savings time. Marc

                                          Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventual

                                          P Offline
                                          P Offline
                                          patbob
                                          wrote on last edited by
                                          #30

                                          Marc Clifton wrote:

                                          Am I missing something obvious? Have you had to deal with this issue?

                                          Yes. You store the time in UTC and then apply any local adjustments at display time. Anything else leads quickly to insanity. Usually, you also give the viewer the choice on whether to see the timestamps in their local time, or in UTC, because people who deal with a lot of timestamps generated in different parts of the globe, rapidly become pretty accustomed to reading them in UTC. The ONLY time it makes sense to use local time, is when the timestamps will only ever be generated, and viewed, in only one time zone, and both are done in the same time zone. The moment you make those timestamps accessible on a network in some way, that assumption breaks, so the smart move is to save the data in UTC, even if you think you'll only ever display it in the timezone it was created in. If the data is in UTC, then you can always upgrade the viewer later.

                                          We can program with only 1's, but if all you've got are zeros, you've got nothing.

                                          L 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