473,834 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

time

can someone explain to me why i get different values for the tm_yday and
tm_isdst values?
import rfc822
rfc822.parsedat e('Mar 1 01:03:59 2004') (2004, 3, 1, 1, 3, 59, 0, 0, 0)
import time
time.strptime(' Mar 1 01:03:59 2004', '%b %d %H:%M:%S %Y')

(2004, 3, 1, 1, 3, 59, 0, 61, -1)
thanks,

bryan
Jul 18 '05 #1
4 2123
Bryan wrote:
can someone explain to me why i get different values for the tm_yday and
tm_isdst values?
>>> import rfc822
>>> rfc822.parsedat e('Mar 1 01:03:59 2004') (2004, 3, 1, 1, 3, 59, 0, 0, 0)
>>> import time
>>> time.strptime(' Mar 1 01:03:59 2004', '%b %d %H:%M:%S %Y')

(2004, 3, 1, 1, 3, 59, 0, 61, -1)

The trivial answer is "because of differences in the modules". Your
question is a bit like asking "Why is the sky today not the same color
as it was yesterday?"

The docs for the time module explain that for strptime(): """The default
values used to fill in any missing data is [sic] (1900, 1, 1, 0, 0, 0,
0, 1, -1)""" and """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). """

Note that strptime used only to be present if your platform's C library
provided it; though I can't say for sure that's changed I believe it
has. No idea when, though.

The rfc822 docs for parsedate, on the other hand, specifically remark
"""Note that fields 6, 7, and 8 of the result tuple are not usable.""".

So I suspect you are simply being disturbed by the lack of a consistency
that was never intended to exist: you reads the docs and makes yer
choice - ultimately, do what works in your application.

carefully-not-mentioning-hobgoblins-ly y'rs - steve
Jul 18 '05 #2
Steve Holden wrote:
Bryan wrote:
can someone explain to me why i get different values for the tm_yday and
tm_isdst values?
>> import rfc822
>> rfc822.parsedat e('Mar 1 01:03:59 2004')

(2004, 3, 1, 1, 3, 59, 0, 0, 0)
>> import time
>> time.strptime(' Mar 1 01:03:59 2004', '%b %d %H:%M:%S %Y')

(2004, 3, 1, 1, 3, 59, 0, 61, -1)

The trivial answer is "because of differences in the modules". Your
question is a bit like asking "Why is the sky today not the same color
as it was yesterday?"


See also:

http://www.python.org/sf/748843

Gerrit.

--
Weather in Twenthe, Netherlands 28/09 08:55:
15.0°C mist overcast wind 4.0 m/s SW (57 m above NAP)
--
In the councils of government, we must guard against the acquisition of
unwarranted influence, whether sought or unsought, by the
military-industrial complex. The potential for the disastrous rise of
misplaced power exists and will persist.
-Dwight David Eisenhower, January 17, 1961
Jul 18 '05 #3
Bryan <be*****@yahoo. com> wrote in message news:<So36d.168 361$3l3.52363@a ttbi_s03>...
can someone explain to me why i get different values for the tm_yday and
tm_isdst values?
>>> import rfc822
>>> rfc822.parsedat e('Mar 1 01:03:59 2004') (2004, 3, 1, 1, 3, 59, 0, 0, 0)
>>> import time
>>> time.strptime(' Mar 1 01:03:59 2004', '%b %d %H:%M:%S %Y') (2004, 3, 1, 1, 3, 59, 0, 61, -1)
thanks,

bryan


I asked a similar question just few days ago. Here is the answer:
time.strptime(' Mar 1 01:03:59 2004 UTC', '%b %d %H:%M:%S %Y %Z')

(2004, 3, 1, 1, 3, 59, 0, 61, 0)

Michele Simionato
Jul 18 '05 #4
Steve Holden <st***@holdenwe b.com> wrote:
...
Note that strptime used only to be present if your platform's C library
provided it; though I can't say for sure that's changed I believe it
has. No idea when, though.


It's changed with 2.3 (thanks to Brett Cannon, who submitted his
pure-Python implementation of strptime, first published in the 1st
edition of the "Python Cookbook").
Alex
Jul 18 '05 #5

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

Similar topics

8
2968
by: Bart Nessux | last post by:
am I doing this wrong: print (time.time() / 60) / 60 #time.time has been running for many hours if time.time() was (21600/60) then that would equal 360/60 which would be 6, but I'm not getting 6 so I'm not doing the division right, any tips?
5
3653
by: David Stockwell | last post by:
I'm sure this has been asked before, but I wasn't able to find it. First off I know u can't change a tuple but if I wanted to increment a time tuple by one day what is the standard method to do that? I've tried the obvious things and haven't gotten very far. I have a time tuple that was created like this: aDate = '19920228' x = time.strptime(aDate,"%Y%m%d")
6
12961
by: David Graham | last post by:
Hi I have asked this question in alt.php as the time() function as used in setcookie belongs to php - or does it belong equally in the javascript camp - bit confused about that. Anyway, can anyone here put me straight on the following: I had a look at the time() function came across this: "To clarify, it seems this function returns the time of the computer's clock and does not do any timezone adjustments to return GMT, so you are...
3
3161
by: Szabolcs Nagy | last post by:
I have to measure the time of a while loop, but with time.clock i always get 0.0s, although python manual sais: "this is the function to use for benchmarking Python or timing algorithms" So i tested timer functions capabilities with a short script: import time import os
6
2859
by: Rebecca Smith | last post by:
Today’s question involves two time text boxes each set to a different time zone. Initially txtCurrentTime will be set to Pacific Time or system time. This will change with system time as we travel across the country. txtRaceTime will always be set to Central Time regardless of where we are in the US. At first I tried ‘Now() – “xx:xx:xx” but that produced an error. Anyway as we approach the east coast the ‘minus’ would need to be a...
3
2727
by: luscus | last post by:
Thanks for all the responses on my first question. Unfortunately the answers I was given were too complicated for my small brain , and neophite condition to understand. So if you could talk down to me and write in easier terms I would be very gratefull to all you access wizards! Here is my problem. I have a table with maybe 10 fields, It is used to imput information taken over the phone to solve patient problems in our Spanish...
3
2037
by: cj | last post by:
If I want to check to see if it's after "11:36 pm" what would I write? I'm sure it's easy but I'm getting tired of having to work with dates and times. Sometimes I just want time or date. And to be able to do comparisons on them.
1
14608
by: davelist | last post by:
I'm guessing there is an easy way to do this but I keep going around in circles in the documentation. I have a time stamp that looks like this (corresponding to UTC time): start_time = '2007-03-13T15:00:00Z' I want to convert it to my local time. start_time = time.mktime(time.strptime(start_time, '%Y-%m-%dT%H:%M:
2
19589
by: Roseanne | last post by:
We are experiencing very slow response time in our web app. We run IIS 6 - windows 2003. I ran iisstate. Here's what I got. Any ideas?? Opened log file 'F:\iisstate\output\IISState-812.log' *********************** Starting new log output
9
8307
by: Ron Adam | last post by:
I'm having some cross platform issues with timing loops. It seems time.time is better for some computers/platforms and time.clock others, but it's not always clear which, so I came up with the following to try to determine which. import time # Determine if time.time is better than time.clock # The one with better resolution should be lower.
0
9796
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9643
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
10789
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
10504
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
10544
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
7755
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
6951
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
5790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.