Peter Hansen wrote:
Tim Peters wrote:
[Peter Hansen]
I think Skip was intending that the format string be mandatory,
to avoid such ambiguity.
It's still a bottomless pit -- ask Brett, who implemented the Python
strptime .
True, I did overlook timezones at the time.
On the other hand, that's b
Tim Peters wrote:
[Peter Hansen]
I think Skip was intending that the format string be mandatory,
to avoid such ambiguity.
It's still a bottomless pit -- ask Brett, who implemented the Python
strptime .
True, I did overlook timezones at the time.
On the other hand, that's because *my* use cases
Tim Peters wrote:
[Skip Montanaro]
I think inputs from strings would be much more common.
Me too, although it's a bottomless pit.
guess-6-intended-meanings-for-1/2/3-before-breakfast-ly y'rs
I think Skip was intending that the format string be mandatory,
to avoid such ambiguity. At least, that's w
[Skip Montanaro]
>>> I think inputs from strings would be much more common.
[Tim Peters]
>> Me too, although it's a bottomless pit.
>>
>> guess-6-intended-meanings-for-1/2/3-before-breakfast-ly y'rs
[Peter Hansen]
> I think Skip was intending that the format string be mandatory,
> to avoid such a
[Skip Montanaro]
> ...
> The datetime.date object already exposes a strftime method for
> generating a formatted string output and will create date objects
> from both time.time() output (fromtimestamp) and "proleptic
> Gregorian ordinal"s (fromordinal). Looking at the datetime module
> docs, it's
Here's how to do it as a one-liner:
python -c "import datetime; import time; print 'Only %d days until
Christmas' % (datetime.date(2004, 12, 25) -
datetime.date.fromtimestamp(time.time())).days"
Here's a slightly shorter way of doing it:
python -c "import time; print 'Only %f more days until Ch
tertius> Is there a more pythonic way to write or do a date difference
tertius> calculation? I have as input two date fields in the form
tertius> '-MM-DD'
How about:
import datetime
import time
bd = "2004-11-25"
ed = "2004-11-30"
start = datetime.date.fromti
Diez B. Roggisch wrote:
>
I can't imagine what could possibly be easier than subtracting two dates -
in fact, most times one has to jump through much more hoops to achieve
these results, e.g. in java.
I'll try that.
Thanks,
T
--
http://mail.python.org/mailman/listinfo/python-list
> bdl = '2004-11-25'.split('-')
> edl = '2004-11-30'.split('-')
> bd = date(int(bdl[0]), int(bdl[1]), int(bdl[2]))
> ed = date(int(edl[0]), int(edl[1]), int(edl[2]))
using time.strptime and datetime.date.fromtimestamp is surely the better
alternative, as it lets specify you the format by a str
Hi,
Is there a more pythonic way to write or do a date difference
calculation? I have as input two date fields in the form '-MM-DD'
TIA
Terius
from datetime import date
bdl = '2004-11-25'.split('-')
edl = '2004-11-30'.split('-')
bd = date(int(bdl[0]), int(bdl[1]), int(bdl[2]))
ed = date(in
10 matches
Mail list logo