[ic] time tag with adjust in February bug?

Gert van der Spoel gert at 3edge.com
Mon Apr 1 09:30:20 UTC 2013


> -----Original Message-----
> From: interchange-users-bounces at icdevgroup.org [mailto:interchange-users-
> bounces at icdevgroup.org] On Behalf Of Paul Jordan
> Sent: maandag 1 april 2013 10:17
> To: interchange-users at icdevgroup.org
> Subject: Re: [ic] time tag with adjust in February bug?
> 
> > users-bounces at icdevgroup.org] On Behalf Of Mike Heins
> > Quoting Peter (peter at pajamian.dhs.org):
> > > On 04/01/2013 12:08 PM, Peter wrote:
> > > >On 04/01/2013 03:27 AM, Paul Jordan wrote:
> > > >>
> > > >>Doing this today:
> > > >>
> > > >>A)    [time]%c[/time] <br />
> > > >>B) - 1d: [time adjust='-1 day']%c[/time] <br />
> > > >>C) - 1m1d: [time adjust='-1 month 1 day']%c[/time] <br />
> > > >>D) - 2m1d: [time  adjust='-2 month 1 day']%c[/time] <br />
> > > >>
> > > >>gives me:
> > > >>
> > > >>A)                Sun Mar 31 07:04:42 2013
> > > >>B) - 1d:        Sat Mar 30 07:04:42 2013
> > > >>C) - 1m1d:   Sat Mar 2 06:04:42 2013
> > > >>D) - 2m1d:   Wed Jan 30 06:04:42 2013
> > > >
> > > >Is your version of Interchange from before or after May of 2009? The
> > > >time adjustment code was completely rewritten then.
> > >
> > > Anyways, after further (off-list) discussion, the server is running
> > > the newer time adjustment code.  having looked through the adjust_time
> > > function again nothing jumps out at me that could cause this.  I would
> > > need to debug on the server to make sure that the correct values are
> > > being passed to mktime().  If so then it's going to be an issue with
> > > POSIX::mktime().
> >
> > There is no "month". 1m is one minute, the "onth" makes no difference.
> > And you can't do addition and subtraction by combining terms...
> >
> > This is April Fool's on European time, no?
> > --
> > Mike Heins
> 
> 
> This bug is quite a coinkidink then:
> 
> [time]%c[/time]<br />
> [time adjust='-12 month']%c[/time]
> [time adjust='-12 month 10 days']%c[/time]
> ----------------------------------------------------
> Mon Apr 1 02:14:17 2013
> Sun Apr 1 02:14:17 2012
> Thu Mar 22 02:15:18 2012


Let me take the bait, april's fool or not ... The 1 minute difference, not
sure ... But for the other ... Same issue you'd see if you take the date of
31st May 2013 and do -1 month 1 day  ... 

What do you expect? 1 month down = April ... April has 30 days .. So 1 month
1 day you'd say is: 29 April ... Well it does not work like that I think,
because I tis fed to mktime 31-1 = 30   4-1=3 ... So that makes April 30th
.. And for the above Feb 30 = March 2 because it compensates the days.

If you take 1st of June and do that -1 month -1 day it is fed to mktime as 
1-1=0   5-1=4     mktime then apparently says: Oh I get 0 that means I need
to take the last day of the previous month (30) and drop the month another
nodge (3) ... So 30th of April and all looks good.

So the bottom line I'd say is: the time_adjust function is faulty as it does
not properly feed information to mktime .. As Mike says: " And you can't do
addition and subtraction by combining terms"  ... The code seems to say: Yes
you can ... But the reality is: with this code you cannot.  

CU,

Gert
 





More information about the interchange-users mailing list