473,749 Members | 2,350 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2188
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.Da teTime object for '2007-03-30 02:43:32.00' at 2b41dd704d40>
>>DateTimeFrom( "Mar 30, 2008 2:43:32 am")
<mx.DateTime.Da teTime 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.D atabase.Adapter ... http://zope.egenix.com/
mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
_______________ _______________ _______________ _______________ ____________

:::: Try mxODBC.Zope.DA for Windows,Linux,S olaris,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...@yaho o.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>\python 25\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>\python 24\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.>>i mport 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*******@yaho o.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>
OverflowErro r: 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
2182
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
10243
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 ta1=(time.strptime('000001', '%H%M%S')) ta2=(time.strptime('230344', '%H%M%S')) t1=time.mktime(ta1) t2=time.mktime(ta2) print t1, t2
16
14342
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 every so often, I get the date 060207 (Feb 7, 2006) which is obviously not correct. When it does this it always gives me this date. I tracked it down to my mktime() call, when I get to a certain date, mktime returns a number in 4000000000,...
7
2421
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
1495
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 Sunday of November" instead of the current setup. http://webexhibits.org/daylightsaving/b.html?y=3000 I am worried because my application deals a lot with Unix timestamps,
2
9562
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 taste of music is "Rag Time Blues" and that os OLD, very OLD music. So it happened I entered a song from the date " 28 dec 1928".
1
3508
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 year, and sets the date to 28th of Febuary, I then need to convert it using mktime(), add the amount of time to move to the next day, then reconvert it in order to take the month and determine whether it is a leap year or not by whether the month is...
2
2768
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 which contain the error are all the same. list($sHour, $sMin, $sSec)=split(':', $startTime2);
0
1028
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 London are booked up and train tickets rocket. If anyone has registered and got their badge and wants to go, let me know. I'm travelling up from Brighton and can pick up en-route with a diversion if necessary. Splitting of petrol for your leg...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9566
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6800
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.