Re: How to add months to a date (datetime object)?

2017-11-22 Thread abiodun . ogunmolu
How about this... from dateutil.relativedelta import relativedelta myDate = datetime.date.today() + relativedelta(months=3) On Sunday, March 15, 2009 at 5:28:24 PM UTC, tin...@isbd.co.uk wrote: > I have a date in the form of a datetime object and I want to add (for > example) three months

Re: Convert pandas series to string and datetime object

2017-09-22 Thread Peter Otten
Pavol Lisy wrote: > pandas is one of reasons why python is so popular these days. But > "there is only milion way how to do it" (and other unpythonic issues) > I see there every time I am looking at it. :) Yeah, such a useful tool with such a byzantine API, completely at odds with the zen -- I w

Re: Convert pandas series to string and datetime object

2017-09-22 Thread Pavol Lisy
;> Out[3]: >> 48173 2017-09-20 04:47:59 >> Name: end, dtype: datetime64[ns] >> >> 1. How to get rid of index value 48173 and get only "2017-09-20 > 04:47:59" >> string? I have to call REST API with "2017-09-20 04:47:59" as a >> parame

Re: Convert pandas series to string and datetime object

2017-09-21 Thread Peter Otten
1.How to get rid of index value 48173 and get only "2017-09-20 04:47:59" > string? I have to call REST API with "2017-09-20 04:47:59" as a parameter, > so I have to get string from pandas datetime64 series. > 2.How to get rid of index value 48173 and get only dat

Re: Convert pandas series to string and datetime object

2017-09-21 Thread MRAB
d get only "2017-09-20 04:47:59" string? I have to call REST API with "2017-09-20 04:47:59" as a parameter, so I have to get string from pandas datetime64 series. 2. How to get rid of index value 48173 and get only datetime object [something like datetime.datetime.strpt

Convert pandas series to string and datetime object

2017-09-21 Thread zljubisic
ring? I have to call REST API with "2017-09-20 04:47:59" as a parameter, so I have to get string from pandas datetime64 series. 2. How to get rid of index value 48173 and get only datetime object [something like datetime.datetime.strptime('2017-09-20 04:47:59', '%Y-%m-%

Re: How to add months to a date (datetime object)?

2017-02-08 Thread John_Gordon
s an answer in response to the original post asking how to add months to a datetime object. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list

Re: How to add months to a date (datetime object)?

2017-02-07 Thread John_Gordon
dateutil.relativedelta import relativedelta > > > > end_date = start_date + relativedelta(months=delta_period) + > > timedelta(days=-delta_period) > Where do you define 'delta_period', and what is your question? There is no question; it is an answer in response to the or

Re: How to add months to a date (datetime object)?

2017-02-07 Thread John_Gordon
relativedelta > > > > end_date = start_date + relativedelta(months=delta_period) + > > timedelta(days=-delta_period) > Where do you define 'delta_period', and what is your question? There is no question; it is an answer in response to the original post asking how to add m

RE: How to add months to a date (datetime object)?

2017-02-06 Thread Deborah Swanson
a_period) > > > >> Where do you define 'delta_period', and what is your question? > > > > There is no question; it is an answer in response to the > original post > > asking how to add months to a datetime object. > > > As far as I can find,

Re: How to add months to a date (datetime object)?

2017-02-06 Thread MRAB
elativedelta > > end_date = start_date + relativedelta(months=delta_period) + > timedelta(days=-delta_period) Where do you define 'delta_period', and what is your question? There is no question; it is an answer in response to the original post asking how to add months to a datetime ob

Re: How to add months to a date (datetime object)?

2017-02-06 Thread John Gordon
> > end_date = start_date + relativedelta(months=delta_period) + > > timedelta(days=-delta_period) > Where do you define 'delta_period', and what is your question? There is no question; it is an answer in response to the original post asking how to add months to a datet

RE: How to add months to a date (datetime object)?

2017-02-06 Thread Deborah Swanson
bajimicb...@gmail.com wrote, on February 02, 2017 2:44 AM > > for start of month to the beginning of next month > > from datetime import timedelta > from dateutil.relativedelta import relativedelta > > end_date = start_date + relativedelta(months=delta_period) + > timedelta(days=-delta_period)

Re: How to add months to a date (datetime object)?

2017-02-02 Thread bajimicbiga
for start of month to the beginning of next month from datetime import timedelta from dateutil.relativedelta import relativedelta end_date = start_date + relativedelta(months=delta_period) + timedelta(days=-delta_period) -- https://mail.python.org/mailman/listinfo/python-list

Re: How can we covert string into Datetime object

2012-05-11 Thread MRAB
On 11/05/2012 12:13, Nikhil Verma wrote: Hi All I was going through this link http://docs.python.org/library/datetime.html#strftime-strptime-behavior. I practised strftime() and strptime() functions. Finally i stuck into a situation where i want to get the datetime object so that i can save

How can we covert string into Datetime object

2012-05-11 Thread Nikhil Verma
Hi All I was going through this link http://docs.python.org/library/datetime.html#strftime-strptime-behavior. I practised strftime() and strptime() functions. Finally i stuck into a situation where i want to get the datetime object so that i can save it in my db. What i want is :- I have a

Re: Struggling to convert a mysql datetime object to a python string of a different format

2011-02-24 Thread Corey Richardson
On 02/24/2011 04:34 AM, rahul mishra wrote: > try this > > test = time.time(2011, 2, 1, 2, 4, 10) > # this is your datetime object from mysql > > print time.mktime(test.timetuple()) > > hope this would help you > > You do realize that email was sent over

Re: Struggling to convert a mysql datetime object to a python string of a different format

2011-02-24 Thread rahul mishra
try this test = time.time(2011, 2, 1, 2, 4, 10) # this is your datetime object from mysql print time.mktime(test.timetuple()) hope this would help you > On Wednesday, August 04, 2010 7:40 PM ? wrote: > Okey, i have many hours now struggling to convert a mysql datetime > fie

Re: DateTime object

2010-11-04 Thread M.-A. Lemburg
jf wrote: > Hi, > > I've a bug in my code and I'm trying de reproduce it. > > To trace the bug I print arguments, and it produces this: > {'date': } > > My question is: what is: ? > > I use mx.DateTime put if I print it I get: > > > So what kind of object is ? You might be using the old Pyt

Re: DateTime object

2010-10-29 Thread jf
Le 29/10/2010 13:41, Adam Tauno Williams a écrit : So what kind of object is ? In this case it is clearly mx.DateTime.DateTime. __repr__ and __str__ may produce different representations; Thanks a lot, in fact it is DateTime from xmlrpclib but your post really helped me to find it. -- htt

Re: DateTime object

2010-10-29 Thread Adam Tauno Williams
On Fri, 2010-10-29 at 13:15 +0200, jf wrote: > Hi, > I've a bug in my code and I'm trying de reproduce it. > To trace the bug I print arguments, and it produces this: > {'date': } > My question is: what is: ? > I use mx.DateTime put if I print it I get: > > So what kind of object is ? In this c

Re: DateTime object

2010-10-29 Thread Luca Bel
Take a look here: http://pypi.python.org/pypi/DateTime/ I always use this package only with Zope (it's an application server) If you are simply working in python maybe it's better to use datetime object. Hi. On Fri, Oct 29, 2010 at 1:15 PM, jf wrote: > Hi, > > I've

DateTime object

2010-10-29 Thread jf
Hi, I've a bug in my code and I'm trying de reproduce it. To trace the bug I print arguments, and it produces this: {'date': } My question is: what is: ? I use mx.DateTime put if I print it I get: So what kind of object is ? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-07 Thread Tim Chase
On 08/07/10 01:45, Νικόλαος Κούρας wrote: # variant B for row in dataset: host, hits, dt = row # rest of your code here So, row is a tuple comprising of 3 fields, and host, hist, dt are variables assigned each one of row's tuple values by breaking it to it's elements. But what

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-07 Thread Νικόλαος Κούρας
Στις 6/8/2010 2:46 πμ, ο/η Tim Chase έγραψε: # variant B for row in dataset: host, hits, dt = row # rest of your code here So, row is a tuple comprising of 3 fields, and host, hist, dt are variables assigned each one of row's tuple values by breaking it to it's elements. But what

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-07 Thread Νίκος
On 6 Αύγ, 08:13, John Nagle wrote: > On 8/4/2010 4:40 PM, Íßêïò wrote: > > >            cursor.execute( ''' SELECT host, hits, date FROM visitors WHERE > > page > > = '%s' ORDER BY date DESC ''' % (page) ) > > Don't do string substitution ("%") on SQL statements.  Let MySQLdb do it > for you, wit

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-05 Thread John Nagle
On 8/4/2010 4:40 PM, Νίκος wrote: cursor.execute( ''' SELECT host, hits, date FROM visitors WHERE page = '%s' ORDER BY date DESC ''' % (page) ) Don't do string substitution ("%") on SQL statements. Let MySQLdb do it for you, with proper escaping: cursor.execute('''SELEC

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-05 Thread Tim Chase
On 08/05/10 16:01, Νίκος wrote: On 5 Αύγ, 22:09, Tim Chase wrote: dataset = cursor.fetchall() for row in dataset: print ( '''''' ) So, 'dataset' in here is a 'list of tuples' right? and 'row' in here is a tuple form the above list of tuples right? Am i understanding this correct

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-05 Thread Νίκος
>On 5 Αύγ, 22:09, Tim Chase wrote: > On 08/05/10 13:52, Νίκος wrote: > > > dataset = cursor.fetchall() > > > for row in dataset: > >      print ( '''  ''' ) As i have it the returned 'dataset' is stored line per line to 'row'. So, 'dataset' in here is a 'list of tuples' right? and 'row' in here

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-05 Thread Tim Chase
On 08/05/10 13:52, Νίκος wrote: dataset = cursor.fetchall() for row in dataset: print ( ''' ''' ) date = row[2].strftime( '%d %b, %H:%M' ) print ( ''' %s %s %s ''' % ( row[0], row[1], date ) ) Unfortunately had to ditch the 'for entry in row' line because cou

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-05 Thread Νίκος
Hey i made it! :-) dataset = cursor.fetchall() for row in dataset: print ( ''' ''' ) date = row[2].strftime( '%d %b, %H:%M' ) print ( ''' %s %s %s ''' % ( row[0], row[1], date ) ) Unfortunately had to ditch the 'for entry in row' line because couldn't iterate over the it

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-05 Thread Νίκος
On 5 Αύγ, 11:55, Dennis Lee Bieber wrote: > On Wed, 4 Aug 2010 16:40:45 -0700 (PDT), Íßêïò > declaimed the following in > gmane.comp.python.general: > > >                    for entry in row: > >                            entry = datetime.datetime.strftime( entry, '%d > > %b, %H:%M' ) #!!! > >

Struggling to convert a mysql datetime object to a python string of a different format

2010-08-04 Thread Νίκος
Okey, i have many hours now struggling to convert a mysql datetime field that i retreive to a string of this format '%d %b, %H:%M' I google a lot but couldnt found out how to format it being a string Here si the code so far: try: cursor.execute( ''' SELECT host, hits, dat

Re: Creating a datetime object from a C Extention

2009-11-30 Thread Martin v. Löwis
= 25, tm_min = 37, tm_hour = 8, tm_mday = 30, tm_mon = 10, > tm_year = 109, tm_wday = 1, tm_yday = 333, tm_isdst = 0, > tm_gmtoff = 0, tm_zone = 0x800fd20c8 "UTC"} > u = 0 > > Is there an Dokumentation or example code HowTo create a datetime object > from a

Creating a datetime object from a C Extention

2009-11-30 Thread Gerhard Schmidt
8, tm_mday = 30, tm_mon = 10, tm_year = 109, tm_wday = 1, tm_yday = 333, tm_isdst = 0, tm_gmtoff = 0, tm_zone = 0x800fd20c8 "UTC"} u = 0 Is there an Dokumentation or example code HowTo create a datetime object from a C Ex

Re: How to add months to a date (datetime object)?

2009-03-16 Thread Lorenzo
On Mar 15, 1:28 pm, tinn...@isbd.co.uk wrote: > I have a date in the form of a datetime object and I want to add (for > example) three months to it.  At the moment I can't see any very > obvious way of doing this.  I need something like:- > >     myDate = datetime.da

Re: How to add months to a date (datetime object)?

2009-03-16 Thread Peter Pearson
On Sun, 15 Mar 2009 16:27:01 -0400, Roy Smith wrote: > In article , > Chris Rebert wrote: > >> Besides your behavior, one could equally well argue that a 31st repeat >> on months without a 31st should just be dropped, or that it should >> carry over onto the 1st of the next month (ignoring the c

Re: How to add months to a date (datetime object)?

2009-03-16 Thread Aahz
In article , John Machin wrote: >On Mar 16, 3:08=A0pm, a...@pythoncraft.com (Aahz) wrote: >> In article , >> Roy Smith =A0 wrote: Besides your behavior, one could equally well argue that a 31st repeat on months without a 31st should just be dropped, or that it should carry ove

Re: How to add months to a date (datetime object)?

2009-03-16 Thread tinnews
Ned Deily wrote: > In article <49bd42ac$0$512$bed64...@news.gradwell.net>, > tinn...@isbd.co.uk wrote: > > I was just hoping there was some calendar object in Python which could > > do all that for me (I need the handling of 31st and February etc.) > > Whatever your requirement, chances are date

Re: How to add months to a date (datetime object)?

2009-03-15 Thread John Machin
On Mar 16, 3:08 pm, a...@pythoncraft.com (Aahz) wrote: > In article , > Roy Smith   wrote: > > >In article , > > Chris Rebert wrote: > > >> Besides your behavior, one could equally well argue that a 31st repeat > >> on months without a 31st should just be dropped, or that it should > >> carry over

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Aahz
In article , Roy Smith wrote: >In article , > Chris Rebert wrote: >> >> Besides your behavior, one could equally well argue that a 31st repeat >> on months without a 31st should just be dropped, or that it should >> carry over onto the 1st of the next month (ignoring the complications >> of Febr

Re: How to add months to a date (datetime object)?

2009-03-15 Thread John Yeung
On Mar 15, 7:26 pm, Chris Rebert wrote: > [...] the point is that there are likewise reasonable usecases > for the other behaviors too and one should refuse to guess in > the face of ambiguity; the std lib has, merely by default in > this case, taken this to the extreme of not implementing any > o

Re: How to add months to a date (datetime object)?

2009-03-15 Thread John Yeung
On Mar 15, 6:25 pm, John Machin wrote: > A couple of issues here: > > (1) The number of days in a month is not a constant, so "a > mathematician's sense of logic" is quite irrelevant. It's relevant in the sense that some commenters on this thread seem to want to apply some semblance of mathematic

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 4:17 PM, Steve Holden wrote: > Roy Smith wrote: >> In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk >> wrote: >> >>> I have a date in the form of a datetime object and I want to add (for >>> example) t

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Steve Holden
Roy Smith wrote: > In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk > wrote: > >> I have a date in the form of a datetime object and I want to add (for >> example) three months to it. At the moment I can't see any very >> obviou

Re: How to add months to a date (datetime object)?

2009-03-15 Thread John Machin
On Mar 16, 6:55 am, John Yeung wrote: > On Mar 15, 3:10 pm, Casey Webster wrote: > > > The example you give does have fairly obvious logic. But how does it > > handle Feb 28th, 2009 + 3 months?  To me, there are two "obvious" > > answers: May 28th, 2009 or May 31st, 2009.  The question is intent;

Re: How to add months to a date (datetime object)?

2009-03-15 Thread John Machin
On Mar 16, 7:30 am, Roy Smith wrote: > In article , >  Chris Rebert wrote: > > > Which makes some sense considering a month can range from 28-31 days, > > which would make the delta oddly fuzzy. > > BTW, what date is "One month after August 10, 1752"?  Extra points if you > refuse the answer the

Re: How to add months to a date (datetime object)?

2009-03-15 Thread CM
On Mar 15, 1:28 pm, tinn...@isbd.co.uk wrote: > I have a date in the form of a datetime object and I want to add (for > example) three months to it.  At the moment I can't see any very > obvious way of doing this.  I need something like:- > >     myDate = datetime.da

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Roy Smith
In article , Chris Rebert wrote: > Not that that date could even be represented by most programs since > it's before 1970. Talk about recentism! :-) > I've always wondered how historians using computers deal with that > limitation... The unix time format it well known for being extremely limit

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 1:30 PM, Roy Smith wrote: > In article , >  Chris Rebert wrote: > >> Which makes some sense considering a month can range from 28-31 days, >> which would make the delta oddly fuzzy. > > BTW, what date is "One month after August 10, 1752"?  Extra points if you > refuse the

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Roy Smith
In article , Chris Rebert wrote: > Which makes some sense considering a month can range from 28-31 days, > which would make the delta oddly fuzzy. BTW, what date is "One month after August 10, 1752"? Extra points if you refuse the answer the question on the grounds that it's incompletely spe

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Roy Smith
In article , Chris Rebert wrote: > Besides your behavior, one could equally well argue that a 31st repeat > on months without a 31st should just be dropped, or that it should > carry over onto the 1st of the next month (ignoring the complications > of February). Which behavior one needs is compl

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Roy Smith
In article <49bd4252$0$512$bed64...@news.gradwell.net>, tinn...@isbd.co.uk wrote: > > Well, before you can "add three months" to something, you need to explain > > what that means. > [...] > No, it's perfectly possible applying simple logic. I didn't say it was not possible. I just said that

Re: How to add months to a date (datetime object)?

2009-03-15 Thread John Yeung
On Mar 15, 3:10 pm, Casey Webster wrote: > The example you give does have fairly obvious logic. But how does it > handle Feb 28th, 2009 + 3 months?  To me, there are two "obvious" > answers: May 28th, 2009 or May 31st, 2009.  The question is intent; is > Feb 28th an arbitrary day of the month, or

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Casey Webster
On Mar 15, 2:00 pm, tinn...@isbd.co.uk wrote: > No, it's perfectly possible applying simple logic.  My reminder > program manages it perfectly well.  I have, for example, two sets of > three monthly reminders. > >     One starts on Jan 19th and repeats three monthly, that means Jan >     19th, Apri

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Ned Deily
In article <49bd42ac$0$512$bed64...@news.gradwell.net>, tinn...@isbd.co.uk wrote: > I was just hoping there was some calendar object in Python which could > do all that for me (I need the handling of 31st and February etc.) Whatever your requirement, chances are dateutil will be of help:

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 11:00 AM, wrote: > Roy Smith wrote: >> In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk >> wrote: >> >> > I have a date in the form of a datetime object and I want to add (for >> > example) three mont

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Andre Engels
On Sun, Mar 15, 2009 at 7:00 PM, wrote: > Roy Smith wrote: >> In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk >> wrote: >> >> > I have a date in the form of a datetime object and I want to add (for >> > example) three mont

Re: How to add months to a date (datetime object)?

2009-03-15 Thread tinnews
Chris Rebert wrote: > On Sun, Mar 15, 2009 at 10:28 AM, wrote: > > I have a date in the form of a datetime object and I want to add (for > > example) three months to it.  At the moment I can't see any very > > obvious way of doing this.  I need somethin

Re: How to add months to a date (datetime object)?

2009-03-15 Thread tinnews
Roy Smith wrote: > In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk > wrote: > > > I have a date in the form of a datetime object and I want to add (for > > example) three months to it. At the moment I can't see any very > &

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Roy Smith
In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk wrote: > I have a date in the form of a datetime object and I want to add (for > example) three months to it. At the moment I can't see any very > obvious way of doing this. I need something li

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Vlastimil Brom
2009/3/15 : > I have a date in the form of a datetime object and I want to add (for > example) three months to it.  At the moment I can't see any very > obvious way of doing this.  I need something like:- > >    myDate = datetime.date.today() >    inc = datetime.timedelt

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 10:28 AM, wrote: > I have a date in the form of a datetime object and I want to add (for > example) three months to it.  At the moment I can't see any very > obvious way of doing this.  I need something like:- > >    myDate = datetime.d

How to add months to a date (datetime object)?

2009-03-15 Thread tinnews
I have a date in the form of a datetime object and I want to add (for example) three months to it. At the moment I can't see any very obvious way of doing this. I need something like:- myDate = datetime.date.today() inc = datetime.timedelta(months=3) myDate += inc but, of c

Re: Parsing a string into a datetime object

2009-01-24 Thread Mark.Petrovic
On Jan 24, 10:56 am, Hrvoje Niksic wrote: > "Mark.Petrovic" writes: > > Might someone comment on why %f is not accepted as a valid field > > directive in: > > from datetime import datetime > created="2009-01-24 16:04:55.882788" > dt = datetime.strptime(created,"%Y-%m-%d %H:%M:%S.%f

Re: Parsing a string into a datetime object

2009-01-24 Thread Hrvoje Niksic
"Mark.Petrovic" writes: > Might someone comment on why %f is not accepted as a valid field > directive in: > from datetime import datetime created="2009-01-24 16:04:55.882788" dt = datetime.strptime(created,"%Y-%m-%d %H:%M:%S.%f") > Traceback (most recent call last): > File "", l

Re: Parsing a string into a datetime object

2009-01-24 Thread MRAB
Mark.Petrovic wrote: > Good day. > > Might someone comment on why %f is not accepted as a valid field > directive in: > from datetime import datetime created="2009-01-24 16:04:55.882788" dt = datetime.strptime(created,"%Y-%m-%d %H:%M:%S.%f") > Traceback (most recent call last): >

Parsing a string into a datetime object

2009-01-24 Thread Mark.Petrovic
Good day. Might someone comment on why %f is not accepted as a valid field directive in: >>> from datetime import datetime >>> created="2009-01-24 16:04:55.882788" >>> dt = datetime.strptime(created,"%Y-%m-%d %H:%M:%S.%f") Traceback (most recent call last): File "", line 1, in File "/System/

Re: serializing datetime object

2007-07-10 Thread Gabriel Genellina
En Tue, 10 Jul 2007 13:13:54 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > I want to serialize datetime.datetime.now() object . I could convert it > to > string but how do I get a datetime object back from the string? > Any suggestions? Use the pickle mo

serializing datetime object

2007-07-10 Thread [EMAIL PROTECTED]
Hi I want to serialize datetime.datetime.now() object . I could convert it to string but how do I get a datetime object back from the string? Any suggestions? thanks mark -- http://mail.python.org/mailman/listinfo/python-list

Re: converting datetime object in UTC to local time

2007-07-06 Thread i3dmaster
How about subclass datetime.tzinfo? That way you can use asttimezone to transfer utc to localtime. It requires an aware object though not naive. A bit more coding, but a lot less converting... Jim On Jul 3, 5:16 pm, Matt <[EMAIL PROTECTED]> wrote: > Hi all, > > So a lot of digging on doing this a

converting datetime object in UTC to local time

2007-07-03 Thread Matt
on gave me something like: mytime = datetime.datetime.fromtimestamp(time.mktime(last_modified_date.utctimetuple()) - time.timezone) lm_date_str = mytime.strftime("%m/%d/%Y %I:%M %p %Z") But this gave me no timezone since the datetime object is still naive. And I'm going from a dat

Re: datetime object from string

2006-02-06 Thread Raymond Hettinger
Douglas Douglas wrote: > Hi everybody. > > I need to create a datetime object from a string like "20/01/2005 15:10:01". I > know the mxDateTime module can do this with the DateTimeFrom method, but I was > wondering if is possible to do this using only the standard library

datetime object from string

2006-02-06 Thread Douglas Douglas
Hi everybody. I need to create a datetime object from a string like "20/01/2005 15:10:01". I know the mxDateTime module can do this with the DateTimeFrom method, but I was wondering if is possible to do this using only the standard library. I read the datetime object reference but did

Re: "zoning" a naive datetime object / daylight savings

2005-08-31 Thread Adam Monsen
Ok, I think I figured this out. Comments/criticisms welcome. --8<-- import datetime, os, time from pytz import UTC old_tz = os.environ.get('TZ') os.environ['TZ'] = 'Europe/Amsterdam' time.tzset() dutchDateParts = (2005, 8, 10, 17, 26,

"zoning" a naive datetime object / daylight savings

2005-08-31 Thread Adam Monsen
e(2005, 8, 10, 15, 34, tzinfo=) What I would *expect* to see is this: >>> d.tzinfo >>> d.astimezone(timezone('UTC')) datetime.datetime(2005, 8, 10, 13, 43, tzinfo=) Any pointers? I feel like pytz/python should be smart enough to know that since the date/time is 15:43 o

Re: How to create datetime object from DbiDate (win32.odbc)?

2005-03-18 Thread Frank Millman
Robert Brewer wrote: > Frank Millman wrote: > > > > First prize would be to have a datetime constructor that takes a > > DbiDate object as input, in the same way that mx does, but this does > > not seem to exist. > > Try: > > datetime.datetime.utcfromtimestamp(int(value)) > Thanks, Robert, this i

Re: How to create datetime object from DbiDate (win32.odbc)?

2005-03-17 Thread Larry Bates
this type, but mx can convert it to a > mx.DateTime object using DateTimeFrom(), which is really all that I > need. > > I am looking into changing from mx.DateTime to using the builtin > datetime type, but I cannot figure out how to convert a DbiDate object > to a datetime object.

RE: How to create datetime object from DbiDate (win32.odbc)?

2005-03-17 Thread Robert Brewer
can convert it to a > mx.DateTime object using DateTimeFrom(), which is really all that I > need. > > I am looking into changing from mx.DateTime to using the builtin > datetime type, but I cannot figure out how to convert a DbiDate object > to a datetime object. > > Fir

How to create datetime object from DbiDate (win32.odbc)?

2005-03-17 Thread Frank Millman
object using DateTimeFrom(), which is really all that I need. I am looking into changing from mx.DateTime to using the builtin datetime type, but I cannot figure out how to convert a DbiDate object to a datetime object. First prize would be to have a datetime constructor that takes a DbiDate object