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.
  • 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
      • M Marc Clifton

        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 Offline
        B Offline
        Brisingr Aerowing
        wrote on last edited by
        #31

        Link fail.

        What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

        1 Reply Last reply
        0
        • M Marc Clifton

          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 Offline
          B Offline
          Brisingr Aerowing
          wrote on last edited by
          #32

          That's also the name of a children's book[^].

          What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

          V 1 Reply Last reply
          0
          • P patbob

            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 Offline
            L Offline
            ledtech3
            wrote on last edited by
            #33

            I agree with this. If you make the time as a UTC then the support person would just need to ask what time zone or state they are in and select that to do the math for them to begin the search in the local time. There are built in .net stuff to check if it is in Day light saving time or not.

            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

              J Offline
              J Offline
              Jeremy Falcon
              wrote on last edited by
              #34

              For that reason I never use local time and always store time values as UTC. Always. Then translating it becomes much much easier, regardless if I want to show my time (server time) for a blog post or the users time (client time) for it. Just calculate the difference in offset before displaying the time. UTC is your friend.

              Jeremy Falcon

              1 Reply Last reply
              0
              • M Marc Clifton

                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 Offline
                J Offline
                Jeremy Falcon
                wrote on last edited by
                #35

                Marc Clifton wrote:

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

                That's still ok. It's much better to have a single authoritative point of reference (UTC) and use that rather than multiple. Take for instance the blog post, that's supposed to be relative to the poster (not the viewer). Even with the time stamp in UTC, calculating the server offset from UTC and showing that to the user, in the servers timezone, is still just as easy. UTC is your friend.

                Jeremy Falcon

                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
                  Pablo Aliskevicius
                  wrote on last edited by
                  #36

                  Take a look at FIFA[^]'S site. At the top of the list of games there is a link that says "change to local time" or "change to your time". You can see scheduled games in your local time (good for watching on TV), and in the local time of wherever the game will take place (good if you're planning to go there and see the game). I saw it for the first time during the 2010 World Cup, and I like it. In general, sport events that are broadcasted to the entire world (the Olympic games start in a few days) pose the same challenge to whoever designs their sites, which are also designed for a wide audience, so this is one place where you can look for inspiration. JM2B, Pablo.

                  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
                    Ryan Peden
                    wrote on last edited by
                    #37

                    In all the scenarios, I'd store the UTC time. And in all cases, I'm assuming you're working in a language that has a decent date/time library available. Ideally it will use something like these time zone ids that are hopefully granular enough to help sort out DST oddities like Indiana (and lots of others). Scenario 1 In the blog's admin section, have a local time zone setting. If there's an admin user logged in, display the blog entry time in the blog's local time zone. So if you travel from NY to CA, if you go to you blog on your laptop and your admin cookie hasn't expired, you'll see the entries in your home time zone. Scanario 2 For non-admin users, show the time in their local time zone. This shouldn't be too hard server-side if you can deduce location from their IP. If you can't, and you're lazy, and you absolutely don't ever want to show post times in the blog's 'home' time zone to users in other time zones, addto every entry, where data-utcmiliis is set to the number of milliseconds since Jan 1, 1970 UTC. On page load, use JavaScript to populate the date fields. The JS Date object has a Date(millis) constructor, so you can instantiate one with the UTC milliseconds value and use that to generate a local date string. So the user will either see the post date in their computer's time zone, or if they have JS disabled they'll see no date at all. Scenario 3 Since the ATMs and branches have specific geographic locations, it's easy to localize transactions. In the case of the no receipt, no cash transaction, I think it makes sense for the customer service rep to ask the customer where it occurred, when it occurred, and the amount of cash the machine should have dispensed. Customer service needs at least some information to determine place and/or time of the transaction. Even an answer like "Last night, in New York, for $50 or $100" or "$250, some time in the past couple of days" would be enough to get started. Start the search based on the customer's card number and pull up the last 25 or 50 transactions. The where/when/amount questions will help the rep quickly scan the list for any transactions matching the customer's description. If the customer can't provide any of these details then they likely need more help than an ATM company's customer service rep can provide. :) It probably makes sense to display the

                    1 Reply Last reply
                    0
                    • B Brisingr Aerowing

                      That's also the name of a children's book[^].

                      What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

                      V Offline
                      V Offline
                      Vikram A Punathambekar
                      wrote on last edited by
                      #38

                      I was nearly 25 when I read it but still enjoyed it! :)

                      Cheers, विक्रम "We have already been through this, I am not going to repeat myself." - fat_boy, in a global warming thread :doh:

                      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

                        N Offline
                        N Offline
                        Nish Nishant
                        wrote on last edited by
                        #39

                        Can't we all agree to just universally use eastern time? :-D

                        Regards, Nish


                        Website: www.voidnish.com Blog: voidnish.wordpress.com

                        M 1 Reply Last reply
                        0
                        • N Nish Nishant

                          Can't we all agree to just universally use eastern time? :-D

                          Regards, Nish


                          Website: www.voidnish.com Blog: voidnish.wordpress.com

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

                          Nish Nishant wrote:

                          Can't we all agree to just universally use eastern time?

                          I agree. That is the most sane thing to do. Unfortunately, the Brits will first be on board with the idea, then after a few years, they'll decide they want to be show their independence and pass a Brex-tix-et referendum. 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

                            W Offline
                            W Offline
                            Worried Brown Eyes
                            wrote on last edited by
                            #41

                            You could always display the length of time since the post was made. I'm sure I've seen that solution used somewhere ;)

                            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

                              G Offline
                              G Offline
                              Gaston Verelst
                              wrote on last edited by
                              #42

                              There is only one correct way: Stardate[^] :-D

                              Check out my blog at http://msdev.pro/

                              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
                                rnbergren
                                wrote on last edited by
                                #43

                                how about when a minute is longer than an hour? Falsehoods programmers believe about time: @noahsussman: Infinite Undo[^] This does happen especially when we live in this virtual server world.

                                To err is human to really mess up you need a computer

                                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
                                  Kirk 10389821
                                  wrote on last edited by
                                  #44

                                  This is actually as complicated as you think it is! Date & Time is location specific (UTC offsets give us that adjustment). We live in FL and have a place in TN (Central time). While we are there, I keep my computer in EDT (NY Time) and talk to the clients only as if NY Time. It is simpler. Next up. Store all time as UTC type time, collect and display it as "local". And then the concept of Local to the customer is displayed to the help desk. As in, it is: xam in Bangalore (Here) 1pm in NY (Our "Company Standard Time") 4pm in Sacramento, CA (Customer Standard Time) The magic is that you have to STORE the customer address/UTC offset. And that should be something you can give them control over. In Oracle, when a session is created, you can set its default time zone, and dates/times will adjust (but this get harry over shared web connections), so a lot of our web code just handled it. Now with SaaS, you have even more issues, because you add: ?pm in Denver ("Their Company Standard Time, as opposed to ours") We fought for some time with DB rules that said "Once a record is entered, after midnight, it cannot be changed"). Yep, it was midnight in NY time, and that was 9PM in CA. They were upset in CA. Luckily they were rarely open that late. BTW, the first part of the conversation (because of all the reminders) is to confirm the time zone with the customer. Because, like myself, they could have traveled elsewhere!

                                  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

                                    S Offline
                                    S Offline
                                    Steven1218
                                    wrote on last edited by
                                    #45

                                    TL;DR the entire discussion, but here is my take for what it's worth. First, all date/time storage should include the UTC code as others stated. As for display let's opt for both sides; display the time local to the current user *and* to the original source location. So for the example about an ATM located in New York with support in the US west coast we would see: 2016-07-29 05:00am [local EDT 2016-07-29 08:00am] That pretty much tells me everything I need to know.

                                    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

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

                                      Incremental searching and some AI. Built a (New Zealand postal) address lookup for a call center: if it starts with a number .... else ... etc. No other input except a single text (search) field; returns x choices which become less the more one types (incremental searching). Also deploying "shipping kiosks": missing labels usually start with a query as to kiosk and shipping destination ("time" is assumed to be recent). A fuzzy search including a $ amount and location seems like a logical place to start with ATM's... (Note that we also incrementally add "transaction info" to a central server while a shipping kiosk "session" for a given customer is in progress; so we always have "something" for a customer that started a session). Oh ... And I store several times: local (kiosk); UTC; "Server" ... To cover my ass.

                                      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

                                        H Offline
                                        H Offline
                                        H Brydon
                                        wrote on last edited by
                                        #47

                                        I've worked on a number of code bases that had to properly handle and manage timestamps. I've never seen a situation yet where the correct thing to do is to store local time. Storing a common time (generally zulu time) without daylight saving time correction is what you need, with a translation from the stored time to local time (including DST correction). Almost every time related bug I've seen is related to violating this principle.

                                        I'm retired. There's a nap for that... - Harvey

                                        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