Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8059 > unrolled thread
| Started by | Junaid P V <junu.pv@gmail.com> |
|---|---|
| First post | 2011-06-20 19:56 -0700 |
| Last post | 2011-06-22 20:55 -0700 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.python
parse date string having "EDT" Junaid P V <junu.pv@gmail.com> - 2011-06-20 19:56 -0700
Re: parse date string having "EDT" Ben Finney <ben+python@benfinney.id.au> - 2011-06-21 14:12 +1000
Re: parse date string having "EDT" Tim Roberts <timr@probo.com> - 2011-06-20 22:52 -0700
Re: parse date string having "EDT" Ben Finney <ben+python@benfinney.id.au> - 2011-06-21 16:10 +1000
Re: parse date string having "EDT" Tim Roberts <timr@probo.com> - 2011-06-22 20:55 -0700
| From | Junaid P V <junu.pv@gmail.com> |
|---|---|
| Date | 2011-06-20 19:56 -0700 |
| Subject | parse date string having "EDT" |
| Message-ID | <b503ac78-b8dd-49bc-b457-c9748d903452@glegroupsg2000goo.googlegroups.com> |
I was trying to parse a date string containing "EDT" time zone
eg: 'Mon Jun 20 14:00:57 EDT 2011'
I tried:
datetime.strptime('Mon Jun 20 14:00:57 EDT 2011', '%a %b %d %H:%M:%S %Z %Y')
But I get error
[toc] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2011-06-21 14:12 +1000 |
| Message-ID | <87oc1rq0ul.fsf@benfinney.id.au> |
| In reply to | #8059 |
Junaid P V <junu.pv@gmail.com> writes:
> I tried:
>
> datetime.strptime('Mon Jun 20 14:00:57 EDT 2011', '%a %b %d %H:%M:%S %Z %Y')
>
> But I get error
When reporting that you get an error, please give the full error and
traceback.
My mind reading skills are telling me, though, that you're getting a
ValueError because you're trying to parse a timezone that is unknown to
the ‘time.strptime’ function. See its documentation for why
<URL:http://docs.python.org/library/time.html#time.strptime>.
--
\ “Give a man a fish, and you'll feed him for a day; give him a |
`\ religion, and he'll starve to death while praying for a fish.” |
_o__) —Anonymous |
Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Tim Roberts <timr@probo.com> |
|---|---|
| Date | 2011-06-20 22:52 -0700 |
| Message-ID | <3ac007lr1fvviek12a96t0oqoo1g6dee5f@4ax.com> |
| In reply to | #8059 |
Junaid P V <junu.pv@gmail.com> wrote:
>
>I was trying to parse a date string containing "EDT" time zone
>
>eg: 'Mon Jun 20 14:00:57 EDT 2011'
>
>I tried:
>
>datetime.strptime('Mon Jun 20 14:00:57 EDT 2011', '%a %b %d %H:%M:%S %Z %Y')
>
>But I get error
Right, because strptime doesn't support %Z. You'll have to handle that
yourself and remove it before conversion.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2011-06-21 16:10 +1000 |
| Message-ID | <87boxrpvds.fsf@benfinney.id.au> |
| In reply to | #8075 |
Tim Roberts <timr@probo.com> writes:
> Right, because strptime doesn't support %Z.
Au contraire:
Support for the %Z directive is based on the values contained in
tzname and whether daylight is true. Because of this, it is
platform-specific except for recognizing UTC and GMT which are
always known (and are considered to be non-daylight savings timezones).
<URL:http://docs.python.org/library/time.html#time.strptime>
--
\ “Human reason is snatching everything to itself, leaving |
`\ nothing for faith.” —Saint Bernard, 1090–1153 |
_o__) |
Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Tim Roberts <timr@probo.com> |
|---|---|
| Date | 2011-06-22 20:55 -0700 |
| Message-ID | <76e50717e469e3tbuurpq39fn7frs6u76i@4ax.com> |
| In reply to | #8077 |
Ben Finney <ben+python@benfinney.id.au> wrote: >Tim Roberts <timr@probo.com> writes: > >> Right, because strptime doesn't support %Z. > >Au contraire: > > Support for the %Z directive is based on the values contained in > tzname and whether daylight is true. Because of this, it is > platform-specific except for recognizing UTC and GMT which are > always known (and are considered to be non-daylight savings timezones). I do keep forgetting that Python's strptime does not just pass through to the C library. C's strptime does not support %Z. -- Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web