473,397 Members | 1,974 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,397 software developers and data experts.

How to obtain GMT offset?

I'm using Windows os. If the current system date time is '28 Jun 2001
14:17:15 +0700', how can I obtain the value '+0700' using python?

Thank you
Aug 16 '05 #1
8 13142
new pip wrote:
I'm using Windows os. If the current system date time is '28 Jun 2001
14:17:15 +0700', how can I obtain the value '+0700' using python?


time.timezone gives you the timezone offset in minutes.

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
Many would be cowards if they had courage enough.
-- Thomas Fuller
Aug 16 '05 #2
new pip wrote:
I'm using Windows os. If the current system date time is '28 Jun 2001
14:17:15 +0700', how can I obtain the value '+0700' using python?

If the current system date is in 2001, obtaining "GMT offset" is the
least of your concerns :-)

Have you read the section on the time module in the Python manual?
If so, what didn't you understand?

One or more of the following might assist:
import time
time.gmtime(), time.localtime() ((2005, 8, 16, 3, 59, 3, 1, 228, 0), (2005, 8, 16, 13, 59, 3, 1, 228, 0)) time.timezone -36000


Looks like it's '-1000' (hours) for me at the moment. Daylight saving
saving isn't operating here at the moment, so I can't tell whether that
makes a difference. I haven't tried to understand the bits about DST in
the manual, but maybe you should.
HTH,
John
Aug 16 '05 #3
new pip wrote:
I'm using Windows os. If the current system date time is '28 Jun 2001
14:17:15 +0700', how can I obtain the value '+0700' using python?

Thank you


If you ignore the time and datetime modules, you can always split
the string on whitespace and grab the last part:
ts='28 Jun 2001 14:17:15 +0700'
tz=ts.split()[-1]
print tz

+0700
Aug 16 '05 #4
Erik Max Francis wrote:
time.timezone gives you the timezone offset in minutes.


Dang, that means I'm twelve days in the past!
import time
time.timezone 18000 18000/60 300
(So that would be hours? ;-) )
18000/60/24

12

Wait up guys!

-Peter
Aug 16 '05 #5
According to <http://www.python.org/doc/2.4.1/lib/module-time.html>
it is in seconds.

--
Mark
On Aug 16, 2005, at 9:35 AM, Peter Hansen wrote:
Erik Max Francis wrote:
time.timezone gives you the timezone offset in minutes.


Dang, that means I'm twelve days in the past!

import time
time.timezone
18000
18000/60
300
(So that would be hours? ;-) )

18000/60/24

12

Wait up guys!

-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Aug 16 '05 #6
On Mon, 15 Aug 2005 20:57:16 -0700, Erik Max Francis <ma*@alcyone.com> wrote:
new pip wrote:
I'm using Windows os. If the current system date time is '28 Jun 2001
14:17:15 +0700', how can I obtain the value '+0700' using python?


time.timezone gives you the timezone offset in minutes.

ITYM seconds?

Regards,
Bengt Richter
Aug 16 '05 #7
On Mon, 15 Aug 2005 20:57:16 -0700, Erik Max Francis <ma*@alcyone.com> wrote:
new pip wrote:
I'm using Windows os. If the current system date time is '28 Jun 2001
14:17:15 +0700', how can I obtain the value '+0700' using python?


time.timezone gives you the timezone offset in minutes.

Hm, ...

From help(time):

Variables:

timezone -- difference in seconds between UTC and local standard time
altzone -- difference in seconds between UTC and local DST time
daylight -- whether local time should reflect DST
tzname -- tuple of (standard time zone name, DST time zone name)

I learned something: there is an altzone variable. But is that a constant,
or is it zero during the standard-time part of the local year? (and since
we do not have module-level properties, what happens if you start python
during standard time and retrieve altzone after 1AM (or whenever the official
switchover happens)? Lack of property would seem to make constants for both
altzone and timezone safer. But then daylight should probably be an accessor
function, if it can't be a property ;-)

Regards,
Bengt Richter
Aug 16 '05 #8
Bengt Richter wrote:
time.timezone gives you the timezone offset in minutes.


ITYM seconds?


I sure did. But at least minutes is a more entertaining answer.

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
If you are afraid of loneliness, do not marry.
-- Anton Chekhov
Aug 17 '05 #9

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

Similar topics

0
by: Christopher Li | last post by:
I am surprised to find out the mmap module in python always mmap from offset 0. So I just hack up some patch to allow it accept offset arguments. So here it is. Chris Add optional offset...
24
by: Christopher Benson-Manica | last post by:
Is there anything wrong with my attempt (below) at implementing something resembling a smart pointer? template < class T > class SmartPointer { private: T *t; public:
4
by: Gactimus | last post by:
Here is a program that encodes and decodes a text file. What I need to do is write a C++ program that requests 3 different file names. One filename is for the source file to be encoded, another is...
4
by: Rithish | last post by:
Is there a way to obtain the height of a <SELECT> element dynamically, i.e. through javascript? I want to dynamically display a list box onFocus of a text box element. Also, if the list box...
0
by: D. Dante Lorenso | last post by:
I need to know that original number of rows that WOULD have been returned by a SELECT statement if the LIMIT / OFFSET where not present in the statement. Is there a way to get this data from PG ?...
10
by: Mark A. Odell | last post by:
Is there a way to obtain the size of a struct element based only upon its offset within the struct? I seem unable to figure out a way to do this (short of comparing every element's offset with...
8
by: printline | last post by:
Hello I have a problem which i hope someone can help me with. I have a website where customers can login and their current and previous orders. What i need now is for the customers to look...
2
by: =?Utf-8?B?Sm9ubnk=?= | last post by:
I have an ASP.NET 2.0 C# web application that is contacting an Exchange server using WEBDAV. It allows the users to look up appointments for a future date. The problem I have is determining the...
8
by: Thomas Mlynarczyk | last post by:
Hello, I want to split a given string into tokens which are defined by regexes: // example tokens - a bit more complex in real $tokens = array( 'NUMBER' ='~^\d+~', 'NAME' ='~^+~', 'ANY' ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.