Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34570
| Date | 2012-12-10 16:36 -0500 |
|---|---|
| From | Dave Angel <d@davea.name> |
| Subject | Re: strptime - dates formatted differently on different computers |
| References | <d564ab7b-9259-4460-813a-10a41e0fcd64@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.685.1355175418.29569.python-list@python.org> (permalink) |
On 12/10/2012 04:18 PM, noydb wrote: > Follow-on question to this earlier topic - https://groups.google.com/d/topic/comp.lang.python/wnUlPBBNah8/discussion For those who avoid googlegroups with a passion, and/or don't have internet access, the subject of that thread is "date-time comparison, aware vs naive", on this same mailing list. > Was curious to know if there was a way to handle different user computers with different operating system set date formats. 2/10/2006 vs 2-10-2006, for example. Not an issue for my current task, but was just curious how this could be handled? > > If in my code I am declaring the user entered date foramtted as > x = datetime.datetime.strptime(user_entered_time , "%m/%d/%Y %I:%M:%S %p") # format for my computer > > but on another person's computer, their's is set as 2-10-2006 14:26:06, the code fails. You can save people a lot of time if you just think before posting. What do you define as failure? is your motherboard smoking, or is the final result off by a second? Please reread my last message on the previous thread. If you want us to give you code advice, show us what you're doing, don't just describe it in vague terms. > Can this be accounted for? When accepting input from a user, consider their environment. Perhaps they're in a different timezone than your program (or your native location), or use some other ordering for the date (for example, the Japanese sensibly put year first, then month, then day. Other regions have different conventions. If you can't detect the user environment, then you'd better tell them yours. For example,by prompting for day, month, and year separately. -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
strptime - dates formatted differently on different computers noydb <jenn.duerr@gmail.com> - 2012-12-10 13:18 -0800
Re: strptime - dates formatted differently on different computers noydb <jenn.duerr@gmail.com> - 2012-12-10 13:22 -0800
Re: strptime - dates formatted differently on different computers Dave Angel <d@davea.name> - 2012-12-10 16:36 -0500
Re: strptime - dates formatted differently on different computers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-11 02:07 +0000
Re: strptime - dates formatted differently on different computers Michael Torrie <torriem@gmail.com> - 2012-12-10 22:34 -0700
Re: strptime - dates formatted differently on different computers Chris Angelico <rosuav@gmail.com> - 2012-12-11 19:08 +1100
Re: strptime - dates formatted differently on different computers Michael Torrie <torriem@gmail.com> - 2012-12-11 01:23 -0700
Re: strptime - dates formatted differently on different computers Michael Torrie <torriem@gmail.com> - 2012-12-11 01:25 -0700
Re: strptime - dates formatted differently on different computers Chris Angelico <rosuav@gmail.com> - 2012-12-11 19:32 +1100
Re: strptime - dates formatted differently on different computers Greg Donald <gdonald@gmail.com> - 2012-12-11 02:35 -0600
Re: strptime - dates formatted differently on different computers noydb <jenn.duerr@gmail.com> - 2012-12-11 06:52 -0800
Re: strptime - dates formatted differently on different computers noydb <jenn.duerr@gmail.com> - 2012-12-11 06:52 -0800
Re: strptime - dates formatted differently on different computers Marc Christiansen <usenet@solar-empire.de> - 2012-12-11 21:18 +0100
Re: strptime - dates formatted differently on different computers Greg Donald <gdonald@gmail.com> - 2012-12-11 23:28 -0600
Re: strptime - dates formatted differently on different computers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-12 05:05 +0000
Re: strptime - dates formatted differently on different computers Greg Donald <gdonald@gmail.com> - 2012-12-11 23:29 -0600
csiph-web