473,221 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

Comparing RFC1123 based Dates

I would like to parse RFC 1123 date format and compare two dates. I
find that
datetime module does not specifically confirms to any RFC. Any
suggestions as how I can handle the RFC 1123 date format using
standard libraries before I go to re based parsing?

Thanks,
Senthil

Aug 5 '07 #1
3 3346
Phoe6 wrote:
I would like to parse RFC 1123 date format and compare two dates. I
find that
datetime module does not specifically confirms to any RFC. Any
suggestions as how I can handle the RFC 1123 date format using
standard libraries before I go to re based parsing?
Well,
>>import time
timeobj = time.strptime("Thu, 01 Dec 1994 16:00:00 GMT","%a, %d %b %Y %H:%M:%S %Z")
was easy.

Thanks,
Senthil

Aug 5 '07 #2
In article <11**********************@e16g2000pri.googlegroups .com>,
Phoe6 <or*******@gmail.comwrites:
Phoe6 wrote:
I would like to parse RFC 1123 date format and compare two dates. I
find that
datetime module does not specifically confirms to any RFC. Any
suggestions as how I can handle the RFC 1123 date format using
standard libraries before I go to re based parsing?

Well,
>import time
timeobj = time.strptime("Thu, 01 Dec 1994 16:00:00 GMT","%a, %d %b %Y %H:%M:%S %Z")

was easy.
Well, it might have been easy, but it's got several gotchas (in
both Python and C), including:

- The zone field (%Z) only corresponds for the GMT and UT timezones,
which are obsolete (see RFC 2822). There is no support for
the recommended +/-time-offset form.

- The day-of-week (%a) and month (%b) fields in strptime and
strftime are subject to the process's locale, whereas the RFC
time forms are not. Those are hardwired to names that happen
to correspond to the C, POSIX, and probably most of the en_*
locales, but not to others that would be used by billions of
people. Thus anyone using your program who doesn't happen to
reside in one of the English-speaking countries (or does and
is using a native locale) is likely to encounter problems when
using your program.

- The day-of-week field is optional.

- Comments are allowed (but deprecated) in the whitespace fields
of the time format. (On the other hand, I've never seen this
is normal e-mail.)

I find the use of strptime and strftime difficult enough to manage
with Internet date/times that I restrict my use of them to programs
that are limited to processing date/times. Even then, I then
explicitly set the locale (LC_TIME) to the "C" locale. Otherwise,
I use ad hoc code that explicitly recognizes the RFC-defined forms.

--
.. Douglas Wells . Connection Technologies .
.. Internet: -sp9804- -at - contek.com- .
Aug 5 '07 #3
Phoe6 wrote:
I would like to parse RFC 1123 date format and compare two dates. I
find that
datetime module does not specifically confirms to any RFC. Any
suggestions as how I can handle the RFC 1123 date format using
standard libraries before I go to re based parsing?
I realise you want to stick to the standard library. If you decide you
can't however, you should definitely take a look at mx.DateTime, as the
mx.DateTime.ARPA submodule provides exactly what you require.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Aug 5 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: F | last post by:
Hi I have posted the question few days back about problem in inserting the dates in SQL server and thankful to them who replied. That was solved and this is a nice solution....
3
by: Harlan Dorado | last post by:
Hi, I'm trying to write a function to compare a date posted from a text field in an asp-page to the date today. The idea is that the date entered in the form field cannot be in the past. This is...
2
by: Duppypog | last post by:
I'm trying to compare a date stored in a database with today's date using an If statement, but it's not returning true. Example, value in database is 11/5/2003 with today being 11/6/2003. Can...
2
by: Manny Chohan | last post by:
Hi, i have two datetime values in format 11/22/04 9:00 AM and 11/22/04 9:30 AM. How can i compare dates .net c# or if there is any other way such as Javascript. Thanks Manny
19
by: Dennis | last post by:
I have a public variable in a class of type color declared as follows: public mycolor as color = color.Empty I want to check to see if the user has specified a color like; if mycolor =...
12
by: colincolehour | last post by:
I am new to Python and am working on my first program. I am trying to compare a date I found on a website to todays date. The problem I have is the website only shows 3 letter month name and the...
4
by: cheryl | last post by:
I am using the PHP.MYSQL and Apache server application in developing my website. I have problem in comparing dates. Website has room reservation, the user will check first the room availability. The...
2
by: dantebothermy | last post by:
Is there a simple way to subtract the time from a datetime field, so when I compare dates, I'm always comparing the dates at 12:00 am? I'd really prefer not to convert all my dates to strings. ...
4
by: jupi13 | last post by:
i have this code..i don't know what where is the error in this one..it says data type mismatch..... Dim Mydate As Date Dim MydateString As String MydateString = "Text1.Text" Mydate =...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.