Re: time between now and the next 2:30 am?

2010-07-24 Thread Jim
On Jul 23, 8:52 pm, MRAB wrote: > > dt_twothirty=dt_localtime.replace(hour=settings.UPDATE_TIME_HOURS,minute=se > > ttings.UPDATE_TIME_MINS,second=0,microsecond=0) > > You're changing the time of day, but not the date. You might want to add > a day to the shutdown time if it's earlier than the cu

Re: time between now and the next 2:30 am?

2010-07-24 Thread John Nagle
On 7/23/2010 10:01 AM, Jim wrote: How can I calculate how much time is between now and the next 2:30 am? Naturally I want the system to worry about leap years, etc. Thanks, Jim DAYSECS = 24*60*60 GOALSECS = (2*60 + 30)*60 now = (GOALSECS + DAYSECS - (int(time.time()) % DAYSECS)) % DA

Re: time between now and the next 2:30 am?

2010-07-23 Thread MRAB
Jim wrote: Thank you again to everyone; I greatly appreciate the help. I ended with essentially what Christian advised and it seems to work fine. FWIW, below is the rouine (I couldn't figure out how to do it without the kludgy x variable). The background is that this is a Django context process

Re: time between now and the next 2:30 am?

2010-07-23 Thread Jim
Thank you again to everyone; I greatly appreciate the help. I ended with essentially what Christian advised and it seems to work fine. FWIW, below is the rouine (I couldn't figure out how to do it without the kludgy x variable). The background is that this is a Django context processor that makes

Re: time between now and the next 2:30 am?

2010-07-23 Thread Christian Heimes
> Your case could be handled by something like: > > from datetime import datetime > from dateutil.relativedelta import relativedelta > > target = datetime.now() + relativedelta(days=+1, hour=2, minute=30, > second=0, microsecond=0) > rem

Re: time between now and the next 2:30 am?

2010-07-23 Thread David Bolen
Neil Cerutti writes: > On 2010-07-23, Jim wrote: >> How can I calculate how much time is between now and the next >> 2:30 am? Naturally I want the system to worry about leap >> years, etc. > > You need the datetime module. Specifically, a datetime and > timedelta object. Although it sounds lik

Re: time between now and the next 2:30 am?

2010-07-23 Thread Jim
Thanks; I'll have a look, and a think. Jim -- http://mail.python.org/mailman/listinfo/python-list

Re: time between now and the next 2:30 am?

2010-07-23 Thread Neil Cerutti
On 2010-07-23, Jim wrote: > How can I calculate how much time is between now and the next > 2:30 am? Naturally I want the system to worry about leap > years, etc. You need the datetime module. Specifically, a datetime and timedelta object. -- Neil Cerutti -- http://mail.python.org/mailman/lis

time between now and the next 2:30 am?

2010-07-23 Thread Jim
How can I calculate how much time is between now and the next 2:30 am? Naturally I want the system to worry about leap years, etc. Thanks, Jim -- http://mail.python.org/mailman/listinfo/python-list