|
BUG: date() object calculations
From: "Terry R. Schussler" <terry@trevimedia.com>
Subject: <lingo-l> BUG: date() object calculations
Be warned that there is a nasty bug in date objects related to math
calculations. The bug is that if you pass a month value where:
(month > 12) AND ((month mod 12) = 0), you will get an extra month tossed
into the resulting date object value:
moreMonths = 11
put date(2000, 12 + moreMonths, 20)
-- date( 2001, 11, 20 )
moreMonths = 12
put date(2000, 12 + moreMonths, 20)
-- date( 2002, 1, 20 )
Here's a snippet of workaround:
moreMonths = 12
extraYears = moreMonths / 12
extraMonths = moreMonths mod 12
put date(2000 + extraYears, 12 + extraMonths, 20)
-- date( 2001, 12, 20 )
|