Pankhuri
1st December 2008, 13:30
There are two cases in which utc.add function is giving incorrect result-
Case 1-
Consider,
i.date = 1 December 2008,
hold.mfsh = 23,
plst.stdt is reference variable.

The utc.add function was written like this-
utc.add (i.date,
0,
-1 * hold.mfsh,
0,
0,
0,
0,
plst.stdt)


After utc.add function is executed plst.stdt comes as 1 January 2006 which is incorrect.
It should come as 1 February 2007.

Case 2-
Consider,
i.date = 1 December 2008,
hold.mfsh = 24,
plst.stdt is reference variable.

The utc.add function was written like this-
hold.mfsh = hold.mfsh - 1
e = utc.add(i.date,
0,
-1 * hold.mfsh,
0,
0,
0,
0,
temp.date)

e = utc.add (temp.date,
0,
-1,
0,
0,
0,
0,
plst.stdt)

here temp.date is temporary variable
After utc.add function is executed plst.stdt comes as 1 January 2005 which is incorrect.
It should come as 1 January 2007.

Does anbody knows why this problem is coming and how to solve this?

Thanks and Regards,
Pankhuri

_Ralph_
1st December 2008, 14:10
Here some examples extracted form Programmers Guide

Example

This example shows the addition of days and hours across winter/summertime change

in_utc = date.to.utc(2002,3,29,13,30,0)

res = utc.add( in_utc, 0, 0, 1, 24, 0, 0, ou_utc )
The result in timezone "Europe/Amsterdam" is: ou_utc=1017577800, res = 0 (that is 2002.3.31 14:30:00)

This example shows the addition of days across winter/summertime change

in_utc = date.to.utc(2002,3,29,13,30,0)

res = utc.add( in_utc, 0, 0, 2, 0, 0, 0, ou_utc )
The result in timezone "Europe/Amsterdam" is: ou_utc=1017574200, res = 0 (that is 2002.3.31 13:30:00)

This example shows the substraction of 1 month from March 31st, 2000.

in_utc = date.to.utc(2000,3,31,9,0,0)

res = utc.add( in_utc, 0, -1, 0, 0, 0, 0, ou_utc )
The result in timezone "Europe/Amsterdam" is: ou_utc=951811200, res = 1 (that is 2000.2.29 9:0:0)

As you can see there are no examples with more then 12 months.

Guess in this situation you should convert 12 months to 1 year.

here worked well.

regards.