Hi. I am creating a couple of small methods to help me manage time from
UTC as standard but I am getting strange results.
If I start with a datetime of 2005-12-12 14:30:00 in timezone
'America/Halifax'
and I want to turn this into a UTC representation.
from datetime import datetime
from pytz.reference import UTC
import pytz
fmt = '%Y-%m-%d %H:%M:%S %Z%z'
tz = pytz.timezone(' America/Halifax')
dt = datetime(year=2 005, month=12, day=11, hour=14, minute=30, second=0,
microsecond=0, tzinfo=tz)
print dt.strftime(fmt )
This is giving me a strange offset of -0414 and LMT timezone.
ie. 2005-12-12 14:30:00 LMT-0414
I am not sure where this is coming from
To get the utc equivalent using dt = dt.astimezone(U TC) I get this
strange result which is obviously also not correct:
# '2005-12-12 18:44:00 UTC+0000'
If I do datetime.now instead with the same timezone I get the correct
timezone and correct offset.
ie.
dt = datetime.now(tz =tz)
# '2005-12-12 21:37:17 AST-0400'
If I get now time from this as utc it is correct
dt = dt.astimezone(U TC)
# '2005-12-12 01:37:17 UTC+0000'
If I do a different timezone of 'America/Vancouver'
I get something appropriate for the 2:30 case
tz = pytz.timezone(' America/Vancouver')
dt = datetime(year=2 005, month=12, day=12, hour=14, minute=30, second=0,
microsecond=0, tzinfo=tz)
print dt.strftime(fmt )
# 2005-12-12 20:30:00 PST-0800
I am not sure why I am getting -0414 and LMT for 'America/Halifax'
timezone? Is this a bug in the pytz package? Many thanks.
Regards,
David 0 1375 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Symon R |
last post by:
This is a bit of a weird one that I haven't yet been able to solve - I'm
hoping someone out there can disprove my findings and tell me where I've
gone wrong!
I have designed a web service that accepts messages from .NET clients. The
web method call includes an object as one of it's parameters - this
reflected object has been given a...
|
by: nicolas_riesch |
last post by:
Does someone know if the module pytz
(http://sourceforge.net/projects/pytz/) is thread-safe ?
I have not seen it explicitely stated, and just wanted to be sure, as I
want to use it.
That's because in the file pytz/tzinfo.py, I see global variables
_timedelta_cache, _datetime_cache, _ttinfo_cache, which are
dictionnaries and are used as...
|
by: Adam Monsen |
last post by:
Say I have the following datetime object:
>>> from datetime import datetime
>>> d = datetime(2005, 8, 10, 15, 43)
I happen to know this is a local time from the Netherlands, so I
assume the tzinfo (if it were present) should indicate Central European
Summer Time ("Summer" indicates daylight savings).
How do I convert this date/time...
|
by: James |
last post by:
I need to import a bunch of data into our database for which there's a
single entry each day which occurs at the same time every day in local
time - so I need to convert this to UTC taking into account local
daylight savings. However daylight savings just don't seem to be
working at all...
Python 2.3.5 (#2, May 4 2005, 08:51:39)
on...
|
by: Phil B |
last post by:
I am having a problem with a datetime from a web services provider
The provider is sending the following SOAP response
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"...
| |
by: Tino Lange |
last post by:
Hi!
I'm surprised about the following code, maybe you can give me a hint whether
that's bug or feature? I'm just trying to convert local time to GMT and one
method gives a strange result:
######################
> #! /usr/bin/env python
>
|
by: Sanjay |
last post by:
Hi All,
I am facing some strange problem in pytz.
The timezone "Asia/Calcutta" is actually IST, which is GMT + 5:30. But
while using pytz, it is being recognized as HMT (GMT + 5:53). While I
digged into the oslan database, I see the following:
# Zone NAME GMTOFF RULES FORMAT
Zone Asia/Calcutta 5:53:28 - LMT 1880 # Kolkata
|
by: Sanjay |
last post by:
Hi All,
I am using pytz.common_timezones to populate the timezone combo box of
some user registration form. But as it has so many timezones (around
400), it is a bit confusing to the users. Is there a smaller and more
practical set? If not, some suggestions on how to handle the
registration form effectively would help me a lot.
thanks...
|
by: _robby |
last post by:
I am looking at using pytz in a scheduling application which will be
used internationally. I would like to be able to update the definition
files that pytz uses monthly or bi-monthly.
As far as I can tell, pytz seems to be updated (fairly) regularly to
the newest tzdata, but I don't want to have to update my pytz, just
it's definitions.
...
|
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...
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |