473,320 Members | 2,146 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,320 software developers and data experts.

mktime overflow in March 2008?

Here's what happens on my Windows machine (Win XP / Cygwin) at work.
I've googled a bit about this problem but only found references to
instances where people referred to dates before the Epoch.

Of course at home on my Linux box everything works.

I know that everything has its limits somewhere, but I've never
heard of March 2008 being a problem.

Tomorrow I'm going to write a test loop that shows me the exact last
second that mktime is going to be able to handle. Sort of like the way
Calvin's father explains the weight limit specification of bridges.

I wonder if the datetime module is any better, considering that under
the hood it probably uses the same C library functions.

I like to stick with the "seconds since..." approach because I need to
store millions of dates/times efficiently in a sqlite database.

$ python
Python 2.5.1 (r251:54863, May 18 2007, 16:56:43)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>import time
t = time.strptime("Mar 30, 2007 2:43:32 am", "%b %d, %Y %I:%M:%S
%p")
time.mktime(t)
1175215412.0
>>t = time.strptime("Mar 30, 2008 2:43:32 am", "%b %d, %Y %I:%M:%S
%p")
time.mktime(t)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range
>>>
robert
Aug 7 '08 #1
5 2170
Dnia 7 Aug 2008 18:40:10 GMT, Robert Latest napisa³(a):
>>>t = time.strptime("Mar 30, 2008 2:43:32 am", "%b %d, %Y %I:%M:%S
%p")
time.mktime(t)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range
>>>>
time module is written in C. time.mktime() function is actually
only a wrapper for mktime(3) and it also has its limits. Better
use datetime module instead.

--
Regards,
Wojtek Walczak,
http://www.stud.umk.pl/~wojtekwa/
Aug 7 '08 #2
On 2008-08-07 20:40, Robert Latest wrote:
Here's what happens on my Windows machine (Win XP / Cygwin) at work.
I've googled a bit about this problem but only found references to
instances where people referred to dates before the Epoch.

Of course at home on my Linux box everything works.

I know that everything has its limits somewhere, but I've never
heard of March 2008 being a problem.

Tomorrow I'm going to write a test loop that shows me the exact last
second that mktime is going to be able to handle. Sort of like the way
Calvin's father explains the weight limit specification of bridges.

I wonder if the datetime module is any better, considering that under
the hood it probably uses the same C library functions.

I like to stick with the "seconds since..." approach because I need to
store millions of dates/times efficiently in a sqlite database.

$ python
Python 2.5.1 (r251:54863, May 18 2007, 16:56:43)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>>import time
t = time.strptime("Mar 30, 2007 2:43:32 am", "%b %d, %Y %I:%M:%S
%p")
time.mktime(t)
1175215412.0
>>>t = time.strptime("Mar 30, 2008 2:43:32 am", "%b %d, %Y %I:%M:%S
%p")
time.mktime(t)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range
Well, you could use the parser in mxDateTime:
>>from mx.DateTime import DateTimeFrom
DateTimeFrom("Mar 30, 2007 2:43:32 am")
<mx.DateTime.DateTime object for '2007-03-30 02:43:32.00' at 2b41dd704d40>
>>DateTimeFrom("Mar 30, 2008 2:43:32 am")
<mx.DateTime.DateTime object for '2008-03-30 02:43:32.00' at 2b41ddd397c0>
>>DateTimeFrom("Mar 30, 2007 2:43:32 am").ticks()
1175215412.0
>>DateTimeFrom("Mar 30, 2008 2:43:32 am").ticks()
1206841412.0

http://www.egenix.com/products/pytho...se/mxDateTime/

--
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source (#1, Aug 07 2008)
>>Python/Zope Consulting and Support ... http://www.egenix.com/
mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
__________________________________________________ ______________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
Aug 7 '08 #3
On Aug 8, 4:40 am, Robert Latest <boblat...@yahoo.comwrote:
Here's what happens on my Windows machine (Win XP / Cygwin) at work.
I've googled a bit about this problem but only found references to
instances where people referred to dates before the Epoch.

Of course at home on my Linux box everything works.
And of course using the official versions of Python for Windows
everything works:

C:\junk>\python25\python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>import time
t = time.strptime("Mar 30, 2008 2:43:32 am", "%b %d, %Y %I:%M:%S %p")
time.mktime(t)
1206805412.0
>>t
(2008, 3, 30, 2, 43, 32, 6, 90, -1)
>>^Z
C:\junk>\python24\python
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>import time
t = time.strptime("Mar 30, 2008 2:43:32 am", "%b %d, %Y %I:%M:%S %p")
time.mktime(t)
1206805412.0
>>t
(2008, 3, 30, 2, 43, 32, 6, 90, -1)
>>>
>
I know that everything has its limits somewhere, but I've never
heard of March 2008 being a problem.

Tomorrow I'm going to write a test loop that shows me the exact last
second that mktime is going to be able to handle. Sort of like the way
Calvin's father explains the weight limit specification of bridges.

I wonder if the datetime module is any better, considering that under
the hood it probably uses the same C library functions.
Don't wonder; try it out; look at the source.
>
I like to stick with the "seconds since..." approach because I need to
store millions of dates/times efficiently in a sqlite database.

$ python
Python 2.5.1 (r251:54863, May 18 2007, 16:56:43)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
There's your problem.
Type "help", "copyright", "credits" or "license" for more information.>>import time
>t = time.strptime("Mar 30, 2007 2:43:32 am", "%b %d, %Y %I:%M:%S
%p")
time.mktime(t)
1175215412.0
>t = time.strptime("Mar 30, 2008 2:43:32 am", "%b %d, %Y %I:%M:%S
%p")
time.mktime(t)

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range
Aug 7 '08 #4
Robert Latest <bo*******@yahoo.comwrote:
>
Here's what happens on my Windows machine (Win XP / Cygwin) at work.
I've googled a bit about this problem but only found references to
instances where people referred to dates before the Epoch.

Of course at home on my Linux box everything works.

I know that everything has its limits somewhere, but I've never
heard of March 2008 being a problem.

Tomorrow I'm going to write a test loop that shows me the exact last
second that mktime is going to be able to handle. Sort of like the way
Calvin's father explains the weight limit specification of bridges.
That's what it's going to sound like when I ask my question.
>...
>>>t = time.strptime("Mar 30, 2008 2:43:32 am", "%b %d, %Y %I:%M:%S
%p")
time.mktime(t)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range
What time zone are you in? March 30, 2008, was a Sunday. If that happened
to be the date your country transitioned to summer time, then the hour
between 2 AM and 3 AM would not exist.

Does it work if you use 3:43 AM?
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Aug 9 '08 #5
Tim Roberts wrote:
What time zone are you in? March 30, 2008, was a Sunday. If that happened
to be the date your country transitioned to summer time, then the hour
between 2 AM and 3 AM would not exist.

Does it work if you use 3:43 AM?
Actually you're right; I'm in Middle Europe, and DST was started on
March 30, 2am. I need to check this.

robert
Aug 9 '08 #6

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

Similar topics

9
by: WebM¤nkey | last post by:
Hi folks Just found that the mktime function returns a negative value when the date is 26 march 2006 with 0 hours, 0 seconds and 0 minutes. Is this a documented problem ? Any suggestions ?
4
by: McBooCzech | last post by:
Hi, on Linux (Fedora FC4) and Python 2.4.1 I am trying to know the time delta in seconds between two times given in the HHMMSS format. My code looks like: import datetime, time...
16
by: John Hanley | last post by:
I created a function that breaks down a date into broken down time, I subtract a certain number of seconds from that, then use mktime() to recompute the calendar time. It works basically except...
7
by: wij | last post by:
Hi: Is there better way of detecting multiplication overflow for type long than by using double precision of lldiv to verify the result? Thanks in advance. I.J.Wang
0
by: Marcus | last post by:
Hello, Is mktime() dependent on PHP or the server's OS? I just read that starting next year, the time switches for daylight saving time will be "on the second Sunday of March and end the first...
2
by: Jorgen Bodde | last post by:
Hi List I am working on an app to store guitar songs I am practicing, and for the fun of it I want to store the date of songs when they were originally made. So far so good.. However, my...
1
by: amhjones | last post by:
Hey I was wondering if anyone could help me with some time code that I am using to determine if a year is a leap year or not. The code I have takes a given year, creates a time structure of the given...
2
by: pedalpete | last post by:
I've got this error which keeps popping up, but I can't seem to figure out why. The error reads ' A non well formed numeric value encountered in filename on line <b>198</b>'. the lines...
0
by: theintrepidfox | last post by:
I'm offering car-sharing to the Microsoft IT Professional UK Launch - Windows Server 2008, SQL Server 2008, Visual Studio 2008 at the Birmingham ICC this Wedneday, 19th March 2008. All flights from...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.