be born on a day that
> doesn't exist. I'd recommend verifying that the data be entered into
> the database is valid.
>
> On Aug 3, 5:37 am, Bram - Smartelectronix <[EMAIL PROTECTED]>
> wrote:
>
> > Hey Everyone,
>
> > does anyone have a good
t;[EMAIL PROTECTED]>
wrote:
> Hey Everyone,
>
> does anyone have a good age in years calculation function for usage with
> datetime.date that returns the age in nr of years of a person?
>
> We were using:
>
> def get_age(self):
> now = datetime.today()
>
On 03-Aug-07, at 10:02 PM, Nis Jørgensen wrote:
>> how about surrounding the statement with a try and work the leap year
>> to regular year case with the exception?
> That seems like overkill. There isn't really any leap-year handling
> necessary:
>
> import datetime.date as date
this should be
On Aug 3, 2007, at 9:57 AM, Doug Van Horn wrote:
def age(d, bday):
> ... return (d.year - bday.year) - \
> ... ((d.month, d.day) < (bday.month, bday.day) and 1 or 0)
Or to be a little more explicit about it:
def age(d, bday):
return (d.year - bday.year) - \
On Aug 3, 11:50 am, Doug Van Horn <[EMAIL PROTECTED]> wrote:
> On Aug 3, 6:37 am, Bram - Smartelectronix <[EMAIL PROTECTED]>
> wrote:
[snip]
You see, you learn something new every day. Based on Nis Jørgensen's
post above, here's a refined age function using the fancy tuple
comparison I didn't kn
On Aug 3, 6:37 am, Bram - Smartelectronix <[EMAIL PROTECTED]>
wrote:
> Hey Everyone,
>
> does anyone have a good age in years calculation function for usage with
> datetime.date that returns the age in nr of years of a person?
>
> We were using:
>
> def get_age(sel
Lucky B skrev:
> how about surrounding the statement with a try and work the leap year
> to regular year case with the exception?
That seems like overkill. There isn't really any leap-year handling
necessary:
import datetime.date as date
def age (d1, d2=None):
if not d2:
d2 = date.to
how about surrounding the statement with a try and work the leap year
to regular year case with the exception?
On Aug 3, 10:16 am, Bram - Smartelectronix <[EMAIL PROTECTED]>
wrote:
> Jonathan Buchanan wrote:
>
> >
>
> >http://toys.jacobian.org/presentations/2007/oscon/tutorial/
>
> > Slide 14, u
Jonathan Buchanan wrote:
>
> http://toys.jacobian.org/presentations/2007/oscon/tutorial/
>
> Slide 14, unit tests too! :)
>>> dob = date(1980,2,29)
>>> dob.replace(year=2007)
Traceback (most recent call last):
File "", line 1, in
ValueError: day is out of range for month
it ain't a part
Interesting. Would this work??
(now - birthday).days * 100 / 36524
Niels
On Aug 3, 1:45 pm, "Jonathan Buchanan" <[EMAIL PROTECTED]>
wrote:
> On 8/3/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hey Everyone,
>
> > do
On 8/3/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>
> Hey Everyone,
>
>
> does anyone have a good age in years calculation function for usage with
> datetime.date that returns the age in nr of years of a person?
>
> We were using:
>
> def get_a
Hey Everyone,
does anyone have a good age in years calculation function for usage with
datetime.date that returns the age in nr of years of a person?
We were using:
def get_age(self):
now = datetime.today()
birthday = datetime(now.year, self.birthday.month, self.birthday.day
12 matches
Mail list logo