I would like to find out if a particular python datetime object is older than X hours or minutes. I am trying to do something similar to:
if (datetime.now() - ...
|
Why doesn't the following work (Python 2.5.2)?
>>> import datetime
>>> class D(datetime.date):
def __init__(self, year):
...
|
How would I generate a random date that has to be between two other given dates?
The functions signature should something like this-
randomDate("1/1/2008 1:30 PM", "1/1/2009 4:50 AM", 0.34)
...
|
I'd like to be able to do the following:
num_intervals = (cur_date - previous_date) / interval_length
or
print (datetime.now() - (datetime.now() - timedelta(days=5)))
/ timedelta(hours=12)
# won't run, would ...
|
My use case is that I'm just making a website that I want people all over the world to be able to use, and I want to be able to say ... |
I'm pretty new to Python and App Engine, but what I'm trying to do is store a model which contains a DateProperty, and that DateProperty is populated with a Date entered ... |
I have a date that is either formatted in German for e.g,
2. Okt. 2009
and also perhaps as
2. Oct. 2009
How do I parse this into an ISO datetime (or python ... |
|
How can I find an age in python from today's date and a persons birthdate? The birthdate is a from a DateField in a Django model.
|
I'm looking for a solution to the following:
Given today's date, figure out what month was before. So 2 should return for today, since it is currently March, the third month of ... |
How to calculate the difference in time in minutes for the following timestamp in python
2010-01-01 17:31:22
2010-01-03 17:31:22
|
I have given date strings like these:
Mon Jun 28 10:51:07 2010
Fri Jun 18 10:18:43 2010
Wed Dec 15 09:18:43 2010
What is a handy python way to calculate the difference in days? Assuming ... |
I am relatively new to Python, and I am experimenting with writing the following date calc functions
- find the date that is/was Monday for a specified datetime
- find the first non-weekend day of ...
|
There appears to be many packages for getting/formatting the current date, or finding out the date n time intervals from now. But I must be overlooking the existence of a simple ... |
I've got a method:
def do_something(year=?, month=?):
pass
I want the year and month arguments to be optional but I want their default to equal the current year and month. ... |
As a matter of general interest I'm wondering if there's a more elegant/efficient way to do this. I have a function that compares two start/end tuples of dates returning true if ... |
How to convert "12/17/2010 4:12:12 PM" to a datetime object?
For eg, If it was like "2007-03-04T21:08:12Z", I would have done
dd =datetime.strptime( "2007-03-04T21:08:12Z", "%Y-%m-%dT%H:%M:%SZ" )
but for time with AM/PM is there any ... |
Seems simple but I just don't know.
I'm interested in serializing a date to a string or integer and sending it from Objective-C to Python, and I want to know if there's ... |
The datetime module provides a method date.isocalendar that, given a date, returns it in the format ([year], [week], [weekday]). How do I go backwards? Given a ([year], [week], [weekday]) tuple, how ... |
ok so this is probably really simple but i have never used the datetime module before
Basically in my code i ask the user for a date in the format dd/mm/yyyy.
currentdate = ...
|
I am trying to compile an old 2008 code.
import datetime
if isinstance(value, datetime.date):
But I got an error:
isinstance() arg 2 must be a class,
type, or ... |
I am trying to subclass the immutable date class in Python, but I also need to override the __str__ method. So far, I have the following:
from datetime import date
class Year(date):
...
|
I am trying to use an OrderedDict (Raymond Hettingers version for pre2.7 Python) where my keys are dates. However it does not order them correctly, I imagine it may ... |
The datetime module does date validation and math which is fine when you care about reality.
I need an object that holds dates generated even if they were invalid. Date time is ... |
Doesn't datetime cover all that date can do? I haven't read all the documentation, but so far I always find myself using datetime.
Even in Django - datetime model fields are ... |