1169d92004-05-02Martin Nilsson START_MARKER
a2eeac2002-11-28Martin Nilsson  dnl NOTE:
3524712015-05-26Martin Nilsson dnl *every* time the Calendar tests have failed, it's not the dnl Calendar module that had any errors. Please don't commit
a2eeac2002-11-28Martin Nilsson dnl your Pike until you've got Calendar to compile again. /Mirar test_true(Calendar.Day())
78401f2003-03-12Martin Nilsson test_eq([[Calendar.Austrian.Day(2500000)->month_day()]],31) test_eq([[Calendar.Coptic.Day(2500000)->month_day()]],25);
a2eeac2002-11-28Martin Nilsson test_eq([[Calendar.Gregorian.Day(2500000)->month_day()]],31) test_eq([[Calendar.ISO.Day(2500000)->month_day()]],31) test_eq([[Calendar.Julian.Day(2500000)->month_day()]],17) test_eq([[(int)(Calendar.Stardate.Tick("julian",2500000)->tic())]],-190335) test_eq(Calendar.ISO.Week(2002,1)->day()->format_ymd(),"2001-12-31")
c7f6a22002-11-21Johan Sundström  test_eval_error(Calendar.ISO.set_timezone("Europe/Stockholm")
a560e52003-03-30Marcus Comstedt  ->dwim_time("2000-03-26 02:01:17"))
8742022008-03-29Martin Nilsson test_eval_error(Calendar.Second()->set_timezone("n"))
c7f6a22002-11-21Johan Sundström 
a560e52003-03-30Marcus Comstedt test_eq(Calendar.ISO_UTC.dwim_time("2000-03-26 02:01:17")->unix_time(), 954036077)
c7f6a22002-11-21Johan Sundström  test_do(Calendar.TimeRange t = Calendar.now()) dnl Some more or less odd timezones encountered by Xenofarm:
bc441a2003-12-31Martin Nilsson define(test_dwim,[[
026bb72004-01-10Dan Nelson  test_eq(Calendar.ISO.set_timezone("CET")->dwim_time($1)->format_time(),"2002-11-19 07:04:03")
b8d5702014-08-28Henrik Grubbström (Grubba)  ifelse($2,,,[[ test_eq(Calendar.ISO.set_timezone("CET")->dwim_time($1)->tzname(),$2) ]])
bc441a2003-12-31Martin Nilsson ]]) test_dwim("Tue Nov 19 07:04:03 MET 2002","MET") test_dwim("Tue Nov 19 07:04:03 CST 2002","CST") test_dwim("Tue Nov 19 07:04:03 CET 2002","CET") test_dwim("Tue Nov 19 07:04:03 2002","CET")
8ae4062012-07-03Henrik Grubbström (Grubba) dnl NFT (Norway-France Time) is the name for CET on AIX. test_dwim("Tue Nov 19 07:04:03 NFT 2002","CET") test_dwim("Tue Nov 19 07:04:03 DFT 2002","CET")
bc441a2003-12-31Martin Nilsson test_dwim("Tue Nov 19 07:04:03 MET DST 2002","MET") test_dwim("Tue Nov 19 07:04:03 METDST 2002","MET")
b3a01d2009-03-11Martin Nilsson test_dwim([["Tue, 19 Nov 2002 07:04:03 GMT"]],"GMT") test_dwim([["Tuesday, 19-Nov-02 07:04:03 GMT"]],"GMT") test_dwim("Tue Nov 19 07:04:03 2002","GMT")
b8d5702014-08-28Henrik Grubbström (Grubba) test_dwim("20021119T070403 GMT","GMT") test_dwim("20021119T070403")
f4918e2014-12-01Henrik Grubbström (Grubba) test_dwim("2002-11-19T07:04:03+0000","UTC") test_dwim("2002-11-19T07:04:03")
b8d5702014-08-28Henrik Grubbström (Grubba) test_dwim("20021119 070403 GMT","GMT") test_dwim("20021119 070403")
b3a01d2009-03-11Martin Nilsson  define(test_http,[[ test_eq(Calendar.ISO.http_time($1)->format_time(),$2) ]]) test_http([["Tue, 19 Nov 2002 07:04:03 GMT"]],"2002-11-19 07:04:03") test_http([["Tuesday, 19-Nov-02 07:04:03 GMT"]],"2002-11-19 07:04:03") test_http("Tue Nov 1 07:04:03 2002","2002-11-01 07:04:03") test_http("Tue Nov 19 07:04:03 2002","2002-11-19 07:04:03")
9d27802002-11-23Johan Sundström  test_eq(arrayp(Calendar.TZnames.zonenames()), 1)
3841da2008-05-16Martin Stjernholm test_do([[ foreach (Calendar.TZnames.zones; string r1; array(string) r2s)
a4d37b2008-05-22Martin Stjernholm  foreach (r2s, string r2)
3841da2008-05-16Martin Stjernholm  Calendar.ISO.Second()->set_timezone (r1 + "/" + r2); ]])
a2eeac2002-11-28Martin Nilsson  dnl FAQ tests test_eq( Calendar.dwim_day("1/2/3"), Calendar.Day(2003,1,2) ) test_eq( Calendar.dwim_day("1 aug 2001"), Calendar.Day(2001,8,1) ) test_false( Calendar.dwim_day("1 aug 2001")==Calendar.Day(2001,8,2) ) dnl Missing two dwim_time tests
c54c282014-01-05Marcus Comstedt test_eq( Calendar.set_timezone("UTC")->parse("%Y-%M-%D %h:%m","2040-11-08 2:46"), Calendar.set_timezone("UTC")->Minute(2040,11,8,2,46) )
a2eeac2002-11-28Martin Nilsson test_false( Calendar.parse("%Y w%W %e %h:%m %p %z","1913 w4 monday 2:14 pm CET")
8168ec2002-12-05Martin Nilsson  < Calendar.set_timezone("CET")->Minute(1913,1,20,14,14) )
a2eeac2002-11-28Martin Nilsson test_false( Calendar.parse("%Y w%W %e %h:%m %p %z","1913 w4 monday 2:14 pm CET")
8168ec2002-12-05Martin Nilsson  > Calendar.set_timezone("CET")->Minute(1913,1,20,14,14) )
063f042008-04-23Martin Nilsson dnl The two objects above are not equal, which really is a bug. dnl Bug 1884 test_equal( Calendar.ISO.parse("%dT%h:%m:%s", "19980717T14:08:55")->set_timezone("UTC"), Calendar.ISO.parse("%dT%h:%m:%s", "19980717T14:08:55")->set_timezone("UTC") ) test_equal( Calendar.ISO.set_timezone("UTC")->parse("%dT%h:%m:%s", "19980717T14:08:55"), Calendar.ISO.set_timezone("UTC")->parse("%dT%h:%m:%s", "19980717T14:08:55") )
537c212012-09-05Martin Stjernholm test_eq(Calendar.parse ("%Y %M %a", "2005 Oct 7"), Calendar.Day (2005, 10, 7)) test_eq(Calendar.parse ("%Y %a", "2005 7"), Calendar.Day (2005, 1, 7))
063f042008-04-23Martin Nilsson 
c0e63f2002-12-11Martin Nilsson  dnl From verify.pike define(test_WDIFF,[[ test_true( $1->week_no() == $2->week_no() ) test_true( $1->week() == $2->week() ) test_true( $1->week()->year() == $2->week()->year() ) ]]) define(test_day,[[ test_do([[
4613242009-08-19Henrik Grubbström (Grubba)  // werror("Testing day %O\n", $1);
c0e63f2002-12-11Martin Nilsson  sscanf($1,"%d-%d-%d %s %dw%d", int y,int m,int d,string wd,int wy,int w); add_constant("d1", Calendar.ISO.Day(y,m,d)); add_constant("d2", Calendar.ISO.dwim_day(y+"-"+m+"-"+d)); add_constant("d3", Calendar.ISO.Week(wy,w)->day(wd)); ]]) test_true( objectp(d1) ) test_true( objectp(d2) ) test_true( objectp(d3) ) test_true( d1==d2 ) test_true( d2==d3 ) test_true( d3==d1 ) test_WDIFF(d1,d2) test_WDIFF(d2,d3) test_WDIFF(d3,d1) test_any([[
7dae3c2008-01-05Henrik Grubbström (Grubba)  sscanf($1, "%*d-%*d-%*d %*s %*dw%d", int w);
c0e63f2002-12-11Martin Nilsson  return w; ]], d1->week_no()) test_any([[
7dae3c2008-01-05Henrik Grubbström (Grubba)  sscanf($1, "%*d-%*d-%*d %*s %dw%*d", int wy);
c0e63f2002-12-11Martin Nilsson  return wy; ]], d1->week()->year_no()) test_do([[ add_constant("d1"); ]]) test_do([[ add_constant("d2"); ]]) test_do([[ add_constant("d3"); ]]) ]]) test_day("1993-12-31 Fri 1993w52") test_day("1994-01-01 Sat 1993w52") test_day("1994-12-31 Sat 1994w52") test_day("1995-01-01 Sun 1994w52") test_day("1995-12-31 Sun 1995w52") test_day("1996-01-01 Mon 1996w01") test_day("1996-12-31 Tue 1997w01") test_day("1997-01-01 Wed 1997w01") test_day("1997-12-31 Wed 1998w01") test_day("1998-01-01 Thu 1998w01") test_day("1998-12-31 Thu 1998w53") test_day("1999-01-01 Fri 1998w53") test_day("1999-12-31 Fri 1999w52") test_day("2000-01-01 Sat 1999w52") test_day("2000-12-31 Sun 2000w52") test_day("2001-01-01 Mon 2001w01") test_day("2003-12-31 Wed 2004w01") test_day("2004-01-01 Thu 2004w01")
0bb2072003-02-11Johan Sundström  test_eq([[ Calendar.ISO.Week(2001, 1)->format_ymd() ]], "2001-01-01") test_eq([[ Calendar.ISO.Week(2002, 1)->format_ymd() ]], "2001-12-31") test_eq([[ Calendar.ISO.Week(2003, 1)->format_ymd() ]], "2002-12-30") test_eq([[ Calendar.ISO.Week(2004, 1)->format_ymd() ]], "2003-12-29") test_eq([[ Calendar.ISO.Week(2005, 1)->format_ymd() ]], "2005-01-03")
138c802003-08-18Martin Stjernholm  test_eq([[Calendar.Language["swe"]->week_day_name_from_number(1)]], "måndag")
431ce62007-01-02Martin Nilsson  test_any([[ object k=Calendar.Events.se["midsummers eve"]->next(Calendar.Year()); return k->second(1)!=k->second(2); ]], 1)
9ec4ca2008-01-23Martin Stjernholm test_eq([[Calendar.ISO.Day (2007, 12, 31)->week()->month_day()]], 31); test_any([[
d5f4582008-05-23Martin Stjernholm  object d = Calendar.ISO.Day (2007, 12, 01);
9ec4ca2008-01-23Martin Stjernholm  d->week_day(); return d->range (d)->week()->year_no(); ]], 2007)
d5f4582008-05-23Martin Stjernholm 
4613242009-08-19Henrik Grubbström (Grubba) dnl From Xuesong Guo <peterpan@wukong.com> test_eq([[((Calendar.dwim_day("20090501")+1)+1)]], [[(Calendar.dwim_day("20090501")+2)]])
76ae432010-12-20Henrik Grubbström (Grubba) dnl From Marc Dirix <marc@dirix.nu> test_any([[ object d = Calendar.Day(); object m = Calendar.Minute()*60; object r = d + d; return (r + m)->minute(); ]], [[ (Calendar.Day() + Calendar.Day() + Calendar.Minute()*60)->minute() ]])
d5f4582008-05-23Martin Stjernholm test_eq([[(Calendar.ISO.Week (2007, 52) + 1)->year_no()]], 2008) test_eq([[Calendar.ISO.Week (2007, 1)->distance (Calendar.ISO.Week (2008, 1))->number_of_weeks()]], 52) test_eq([[Calendar.ISO.Year(2007)->year()->year_no()]], 2007) test_eq([[Calendar.ISO.Year(2007)->year(1)->year_no()]], 2007) test_eq([[Calendar.ISO.Year(2007)->year(-1)->year_no()]], 2007) test_eq([[Calendar.ISO.Year(2007)->set_size(2)->year()->year_no()]], 2007) test_eq([[Calendar.ISO.Year(2007)->set_size(2)->year(1)->year_no()]], 2007) test_eq([[Calendar.ISO.Year(2007)->set_size(2)->year(2)->year_no()]], 2008) test_eq([[Calendar.ISO.Year(2007)->set_size(2)->year(-2)->year_no()]], 2007) test_eq([[Calendar.ISO.Year(2007)->set_size(2)->year(-1)->year_no()]], 2008) test_equal([[Calendar.ISO.Year(2007)->set_size(2)->years()->year_no()]], ({2007, 2008})) test_equal([[Calendar.ISO.Year(2007)->set_size(2)->years(1,1)->year_no()]], ({2007})) test_equal([[Calendar.ISO.Year(2007)->set_size(2)->years(2,2)->year_no()]], ({2008})) test_equal([[Calendar.ISO.Year(2007)->set_size(2)->years(1,2)->year_no()]], ({2007, 2008})) test_equal([[Calendar.ISO.Year(2007)->set_size(2)->years(0,2)->year_no()]], ({2007, 2008})) test_equal([[Calendar.ISO.Year(2007)->set_size(2)->years(1,3)->year_no()]], ({2007, 2008})) test_eq([[Calendar.ISO.Month(2007,7)->month()->month_no()]], 7) test_eq([[Calendar.ISO.Month(2007,7)->month(1)->month_no()]], 7) test_eq([[Calendar.ISO.Month(2007,7)->month(-1)->month_no()]], 7) test_eq([[Calendar.ISO.Month(2007,7)->set_size(2)->month()->month_no()]], 7) test_eq([[Calendar.ISO.Month(2007,7)->set_size(2)->month(1)->month_no()]], 7) test_eq([[Calendar.ISO.Month(2007,7)->set_size(2)->month(2)->month_no()]], 8) test_eq([[Calendar.ISO.Month(2007,7)->set_size(2)->month(-2)->month_no()]], 7) test_eq([[Calendar.ISO.Month(2007,7)->set_size(2)->month(-1)->month_no()]], 8) test_equal([[Calendar.ISO.Month(2007,7)->set_size(2)->months()->month_no()]], ({7, 8})) test_equal([[Calendar.ISO.Month(2007,7)->set_size(2)->months(1,1)->month_no()]], ({7})) test_equal([[Calendar.ISO.Month(2007,7)->set_size(2)->months(2,2)->month_no()]], ({8})) test_equal([[Calendar.ISO.Month(2007,7)->set_size(2)->months(1,2)->month_no()]], ({7, 8})) test_equal([[Calendar.ISO.Month(2007,7)->set_size(2)->months(0,2)->month_no()]], ({7, 8})) test_equal([[Calendar.ISO.Month(2007,7)->set_size(2)->months(1,3)->month_no()]], ({7, 8})) test_eq([[Calendar.ISO.Week(2007,7)->week()->week_no()]], 7) test_eq([[Calendar.ISO.Week(2007,7)->week(1)->week_no()]], 7) test_eq([[Calendar.ISO.Week(2007,7)->week(-1)->week_no()]], 7) test_eq([[Calendar.ISO.Week(2007,7)->set_size(2)->week()->week_no()]], 7) test_eq([[Calendar.ISO.Week(2007,7)->set_size(2)->week(1)->week_no()]], 7) test_eq([[Calendar.ISO.Week(2007,7)->set_size(2)->week(2)->week_no()]], 8) test_eq([[Calendar.ISO.Week(2007,7)->set_size(2)->week(-2)->week_no()]], 7) test_eq([[Calendar.ISO.Week(2007,7)->set_size(2)->week(-1)->week_no()]], 8) test_equal([[Calendar.ISO.Week(2007,7)->set_size(2)->weeks()->week_no()]], ({7, 8})) test_equal([[Calendar.ISO.Week(2007,7)->set_size(2)->weeks(1,1)->week_no()]], ({7})) test_equal([[Calendar.ISO.Week(2007,7)->set_size(2)->weeks(2,2)->week_no()]], ({8})) test_equal([[Calendar.ISO.Week(2007,7)->set_size(2)->weeks(1,2)->week_no()]], ({7, 8})) test_equal([[Calendar.ISO.Week(2007,7)->set_size(2)->weeks(0,2)->week_no()]], ({7, 8})) test_equal([[Calendar.ISO.Week(2007,7)->set_size(2)->weeks(1,3)->week_no()]], ({7, 8})) test_eq([[Calendar.ISO.Day(2007,7,7)->day()->month_day()]], 7) test_eq([[Calendar.ISO.Day(2007,7,7)->day(1)->month_day()]], 7) test_eq([[Calendar.ISO.Day(2007,7,7)->day(-1)->month_day()]], 7) test_eq([[Calendar.ISO.Day(2007,7,7)->set_size(2)->day()->month_day()]], 7) test_eq([[Calendar.ISO.Day(2007,7,7)->set_size(2)->day(1)->month_day()]], 7) test_eq([[Calendar.ISO.Day(2007,7,7)->set_size(2)->day(2)->month_day()]], 8) test_eq([[Calendar.ISO.Day(2007,7,7)->set_size(2)->day(-2)->month_day()]], 7) test_eq([[Calendar.ISO.Day(2007,7,7)->set_size(2)->day(-1)->month_day()]], 8) test_equal([[Calendar.ISO.Day(2007,7,7)->set_size(2)->days()->month_day()]], ({7, 8})) test_equal([[Calendar.ISO.Day(2007,7,7)->set_size(2)->days(1,1)->month_day()]], ({7})) test_equal([[Calendar.ISO.Day(2007,7,7)->set_size(2)->days(2,2)->month_day()]], ({8})) test_equal([[Calendar.ISO.Day(2007,7,7)->set_size(2)->days(1,2)->month_day()]], ({7, 8})) test_equal([[Calendar.ISO.Day(2007,7,7)->set_size(2)->days(0,2)->month_day()]], ({7, 8})) test_equal([[Calendar.ISO.Day(2007,7,7)->set_size(2)->days(1,3)->month_day()]], ({7, 8})) test_eq([[Calendar.ISO.Year (Calendar.ISO.Month (2007, 12)->set_size (2))->nice_print_period()]], "2007..2008") test_eq([[Calendar.ISO.Year (Calendar.ISO.Week (2007, 52)->set_size (2))->nice_print_period()]], "2007..2008") test_eq([[Calendar.ISO.Year (Calendar.ISO.Day (2007, 12, 31)->set_size (2))->nice_print_period()]], "2007..2008") test_equal([[Calendar.ISO.Year (Calendar.ISO.Month (2007, 12)->set_size (2))->years()->year_no()]], ({2007, 2008})) test_equal([[Calendar.ISO.Year (Calendar.ISO.Week (2007, 52)->set_size (2))->years()->year_no()]], ({2007, 2008})) test_equal([[Calendar.ISO.Year (Calendar.ISO.Day (2007, 12, 31)->set_size (2))->years()->year_no()]], ({2007, 2008})) test_eq([[Calendar.ISO.Month (Calendar.ISO.Week (2007, 52)->set_size (2))->nice_print_period()]], "December 2007 .. January 2008") test_eq([[Calendar.ISO.Month (Calendar.ISO.Day (2007, 12, 31)->set_size (2))->nice_print_period()]], "December 2007 .. January 2008") test_eq([[Calendar.ISO.Month (2008, 2)->week (1)]], Calendar.ISO.Week (2008, 5)) test_eq([[Calendar.ISO.Month (2008, 2)->week (-1)]], Calendar.ISO.Week (2008, 9)) test_eq([[Calendar.ISO.Month (2008, 2)->week (5)]], Calendar.ISO.Week (2008, 9)) test_eval_error([[Calendar.ISO.Month (2008, 2)->week (6)]]) dnl This is a bit counterintuitive but it's consistent with weeks dnl overlapping months. test_eq([[Calendar.ISO.Year (2004)->week (-1)]], Calendar.ISO.Week (2004, 53)) test_eq([[Calendar.ISO.Year (2005)->week (1)]], Calendar.ISO.Week (2004, 53)) test_eq([[Calendar.ISO.Year (2005)->week (-1)]], Calendar.ISO.Week (2005, 52)) test_eq([[Calendar.ISO.Year (2006)->week (1)]], Calendar.ISO.Week (2005, 52)) test_eq([[Calendar.ISO.Year (2006)->week (-1)]], Calendar.ISO.Week (2006, 52)) test_eq([[Calendar.ISO.Year (2007)->week (1)]], Calendar.ISO.Week (2007, 1)) dnl Tests for year spanning weeks.
9ec4ca2008-01-23Martin Stjernholm test_eq([[Calendar.ISO.Day (2007, 12, 31)->format_iso_week()]], "2008-W01") test_eq([[Calendar.ISO.Day (2007, 12, 31)->format_iso_week_short()]], "200801") test_eq([[Calendar.ISO.Day (2007, 12, 31)->set_size (Calendar.ISO.Week())->format_iso_week()]], "2008-W01") test_eq([[Calendar.ISO.Day (2007, 12, 31)->set_size (Calendar.ISO.Week())->year_no()]], 2008) test_eq([[Calendar.ISO.Week (2008, 1)->set_size (Calendar.ISO.Day())->format_ymd()]], "2007-12-31") test_eq([[Calendar.ISO.Week (2008, 1)->set_size (Calendar.ISO.Day())->year_no()]], 2007) test_eq([[Calendar.ISO.Week (2008, 1)->year_no()]], 2008)
d5f4582008-05-23Martin Stjernholm test_eq([[Calendar.ISO.Week (2008, 1)->year_day()]], 0) test_equal([[Calendar.ISO.Week ("julian", 2454466)->format_iso_week()]], "2008-W01")
82342e2010-03-02Henrik Grubbström (Grubba) dnl [bug 5303] test_eq([[Calendar.ISO.Week("unix",1262300400)->month_day()]], 28)
d5f4582008-05-23Martin Stjernholm  test_equal([[ Calendar.ISO.Week (2008, 1)->datetime() - (["timezone": 1, "unix": 1]) ]], [[ ([ "day": 31, "fraction": 0.0, "hour": 0, "julian": 2454466, "minute": 0, "month": 12, "second": 0, "week": 53, "week_day": 1, "year": 2007, "yearday": 364 ]) ]]) test_equal([[Calendar.ISO.Day (Calendar.ISO.Week(2008,1))->years()->year_no()]], ({2007, 2008})) test_equal([[Calendar.ISO.Month (Calendar.ISO.Week(2008,1))->years()->year_no()]], ({2007, 2008})) test_equal([[Calendar.ISO.Year (Calendar.ISO.Week(2008,1))->years()->year_no()]], ({2007, 2008})) test_equal([[Calendar.ISO.Week(2008,1)->years()->year_no()]], ({2007, 2008})) test_equal([[Calendar.ISO.Week(2008,1)->number_of_years()]], 2) test_eq([[Calendar.ISO.Year (Calendar.ISO.Week (2008, 1))->year_no()]], 2007) test_eq([[Calendar.ISO.Year (Calendar.ISO.Week (2008, 1))->number_of_years()]], 2) test_equal([[Calendar.ISO.Year (Calendar.ISO.Week (2008, 1))->years()->year_no()]], ({2007, 2008}))
9ec4ca2008-01-23Martin Stjernholm 
7a51702008-02-05Martin Stjernholm test_eq([[Calendar.ISO.Day (2007, 5, 31)->add (1, Calendar.ISO.Month())]], Calendar.ISO.Day (2007, 6, 30)) test_eq([[Calendar.ISO.Day (2007, 5, 31)->add (2, Calendar.ISO.Month())]], Calendar.ISO.Day (2007, 7, 31)) test_eq([[Calendar.ISO.Day (2007, 5, 31)->add (1, Calendar.ISO.Month())->add (1, Calendar.ISO.Month())]], Calendar.ISO.Day (2007, 7, 30)) test_eq([[Calendar.ISO.Day (2007, 5, 31)->add (-1, Calendar.ISO.Month())]], Calendar.ISO.Day (2007, 4, 30)) test_eq([[Calendar.ISO.Day (2007, 5, 31)->add (-2, Calendar.ISO.Month())]], Calendar.ISO.Day (2007, 3, 31)) test_eq([[Calendar.ISO.Day (2007, 5, 31)->add (-1, Calendar.ISO.Month())->add (1, Calendar.ISO.Month())]], Calendar.ISO.Day (2007, 5, 30)) test_eq([[Calendar.ISO.Day (1900, 1, 31)->add (1, Calendar.ISO.Month())]], Calendar.ISO.Day (1900, 2, 28)) test_eq([[Calendar.ISO.Day (2000, 1, 31)->add (1, Calendar.ISO.Month())]], Calendar.ISO.Day (2000, 2, 29)) test_eq([[Calendar.ISO.Day (2004, 1, 31)->add (1, Calendar.ISO.Month())]], Calendar.ISO.Day (2004, 2, 29)) test_eq([[Calendar.ISO.Day (2004, 2, 29)->add (1, Calendar.ISO.Year())]], Calendar.ISO.Day (2005, 2, 28)) test_eq([[Calendar.ISO.Day (2004, 2, 29)->add (4, Calendar.ISO.Year())]], Calendar.ISO.Day (2008, 2, 29)) test_eq([[Calendar.ISO.Day (2004, 2, 29)->add (2, Calendar.ISO.Year())->add (2, Calendar.ISO.Year())]], Calendar.ISO.Day (2008, 2, 28)) test_eq([[Calendar.ISO.Day (2004, 2, 29)->add (-1, Calendar.ISO.Year())]], Calendar.ISO.Day (2003, 2, 28)) test_eq([[Calendar.ISO.Day (2004, 2, 29)->add (-4, Calendar.ISO.Year())]], Calendar.ISO.Day (2000, 2, 29)) test_eq([[Calendar.ISO.Day (2004, 2, 29)->add (-2, Calendar.ISO.Year())->add (2, Calendar.ISO.Year())]], Calendar.ISO.Day (2004, 2, 28))
d5f4582008-05-23Martin Stjernholm test_eq([[Calendar.ISO.Week (2003, 52)->add (1, Calendar.ISO.Year())]], Calendar.ISO.Week (2004, 52)) test_eq([[Calendar.ISO.Week (2003, 52)->add (1, Calendar.ISO.Year())->add (1, Calendar.ISO.Year())]], Calendar.ISO.Week (2005, 52)) test_eq([[Calendar.ISO.Week (2004, 53)->add (1, Calendar.ISO.Year())]], Calendar.ISO.Week (2005, 52)) test_eq([[Calendar.ISO.Week (2004, 53)->add (5, Calendar.ISO.Year())]], Calendar.ISO.Week (2009, 53)) test_eq([[Calendar.ISO.Week (2004, 53)->add (2, Calendar.ISO.Year())->add (3, Calendar.ISO.Year())]], Calendar.ISO.Week (2009, 52)) test_eq([[Calendar.ISO.Week (2004, 53)->add (-1, Calendar.ISO.Year())]], Calendar.ISO.Week (2003, 52)) test_eq([[Calendar.ISO.Week (2004, 53)->add (-6, Calendar.ISO.Year())]], Calendar.ISO.Week (1998, 53)) test_eq([[Calendar.ISO.Week (2004, 53)->add (-3, Calendar.ISO.Year())->add (3, Calendar.ISO.Year())]], Calendar.ISO.Week (2004, 52)) test_eq([[Calendar.ISO.Day (1996, 2, 24)->add (1, Calendar.ISO.Year())]], Calendar.ISO.Day (1997, 2, 24)) test_eq([[Calendar.ISO.Day (1996, 2, 26)->add (1, Calendar.ISO.Year())]], Calendar.ISO.Day (1997, 2, 25)) test_eq([[Calendar.ISO.Day (1996, 2, 29)->add (1, Calendar.ISO.Year())]], Calendar.ISO.Day (1997, 2, 28)) test_eq([[Calendar.ISO.Day (1996, 2, 24)->add (8, Calendar.ISO.Year())]], Calendar.ISO.Day (2004, 2, 24)) test_eq([[Calendar.ISO.Day (1996, 2, 26)->add (8, Calendar.ISO.Year())]], Calendar.ISO.Day (2004, 2, 26)) test_eq([[Calendar.ISO.Day (1996, 2, 29)->add (8, Calendar.ISO.Year())]], Calendar.ISO.Day (2004, 2, 29)) test_eq([[Calendar.Gregorian.Year (2005)->place (Calendar.Gregorian.Day (2004, 2, 24))]], 0) test_eq([[Calendar.Gregorian.Year (2005)->place (Calendar.Gregorian.Day (2004, 2, 26))]], Calendar.Gregorian.Day (2005, 2, 25)) test_eq([[Calendar.Gregorian.Year (2005)->place (Calendar.Gregorian.Day (2004, 2, 29))]], Calendar.Gregorian.Day (2005, 2, 28)) test_eq([[Calendar.Gregorian.Year (2005)->place (Calendar.Gregorian.Day (2004, 2, 24), 1)]], Calendar.Gregorian.Day (2005, 2, 24)) test_eq([[Calendar.Gregorian.Year (2005)->place (Calendar.Gregorian.Day (2004, 3, 1), 1)]], Calendar.Gregorian.Day (2005, 3, 1)) test_eq([[Calendar.Gregorian.Month (2005, 2)->place (Calendar.Gregorian.Day (2004, 2, 24))]], 0) test_eq([[Calendar.Gregorian.Month (2005, 2)->place (Calendar.Gregorian.Day (2004, 2, 26))]], Calendar.Gregorian.Day (2005, 2, 25)) test_eq([[Calendar.Gregorian.Month (2005, 2)->place (Calendar.Gregorian.Day (2004, 2, 29))]], Calendar.Gregorian.Day (2005, 2, 28)) test_eq([[Calendar.Gregorian.Month (2005, 2)->place (Calendar.Gregorian.Day (2004, 2, 24), 1)]], Calendar.Gregorian.Day (2005, 2, 24)) test_eq([[Calendar.Gregorian.Month (2005, 3)->place (Calendar.Gregorian.Day (2004, 3, 1), 1)]], Calendar.Gregorian.Day (2005, 3, 1)) test_eq([[Calendar.ISO.Year (2005)->place (Calendar.ISO.Day (2004, 2, 24))]], Calendar.ISO.Day (2005, 2, 24)) test_eq([[Calendar.ISO.Year (2005)->place (Calendar.ISO.Day (2004, 2, 26))]], Calendar.ISO.Day (2005, 2, 26)) test_eq([[Calendar.ISO.Year (2005)->place (Calendar.ISO.Day (2004, 2, 29))]], 0) test_eq([[Calendar.ISO.Year (2005)->place (Calendar.ISO.Day (2004, 2, 29), 1)]], Calendar.ISO.Day (2005, 2, 28)) test_eq([[Calendar.ISO.Year (2005)->place (Calendar.ISO.Day (2004, 3, 1), 1)]], Calendar.ISO.Day (2005, 3, 1)) test_eq([[Calendar.ISO.Month (2005, 2)->place (Calendar.ISO.Day (2004, 2, 24))]], Calendar.ISO.Day (2005, 2, 24)) test_eq([[Calendar.ISO.Month (2005, 2)->place (Calendar.ISO.Day (2004, 2, 26))]], Calendar.ISO.Day (2005, 2, 26)) test_eq([[Calendar.ISO.Month (2005, 2)->place (Calendar.ISO.Day (2004, 2, 29))]], 0) test_eq([[Calendar.ISO.Month (2005, 2)->place (Calendar.ISO.Day (2004, 2, 29), 1)]], Calendar.ISO.Day (2005, 2, 28)) test_eq([[Calendar.ISO.Month (2005, 3)->place (Calendar.ISO.Day (2004, 3, 1), 1)]], Calendar.ISO.Day (2005, 3, 1))
ffc8602014-12-03Henrik Grubbström (Grubba) dnl Calendar.ISO.deltat dnl dnl year, deltat, error define([[test_deltat]], [[ test_any([[ int t = ($1 - 1970) * 31556952; float dt = Calendar.ISO.deltat(t) + $3; if (dt < $2) return dt; return 0; ]], 0) test_any([[ int t = ($1 - 1970) * 31556952; float dt = Calendar.ISO.deltat(t) - $3; if (dt > $2) return dt; return 0; ]], 0) ]]) dnl Table 2-1 from http://eclipse.gsfc.nasa.gov/5MCSE/5MCSE-Text11.pdf test_deltat( -500, 17190, 430) test_deltat( -400, 15530, 390) test_deltat( -300, 14080, 360) test_deltat( -200, 12790, 330) test_deltat( -100, 11640, 290) test_deltat( 0, 10580, 260) test_deltat( 100, 9600, 240) test_deltat( 200, 8640, 210) test_deltat( 300, 7680, 180) test_deltat( 400, 6700, 160) test_deltat( 500, 5710, 140) test_deltat( 600, 4740, 120) test_deltat( 700, 3810, 100) test_deltat( 800, 2960, 80) test_deltat( 900, 2200, 70) test_deltat( 1000, 1570, 55) test_deltat( 1100, 1090, 40) test_deltat( 1200, 740, 30) test_deltat( 1300, 490, 20) test_deltat( 1400, 320, 20) test_deltat( 1500, 200, 20) test_deltat( 1600, 120, 20) test_deltat( 1700, 9, 5) test_deltat( 1750, 13, 2) test_deltat( 1800, 14, 1) test_deltat( 1850, 7, 1) test_deltat( 1900, -3, 1) test_deltat( 1950, 29, 0.1) dnl Table 2-2 from http://eclipse.gsfc.nasa.gov/5MCSE/5MCSE-Text11.pdf test_deltat(1955, 31.1, 0.08) test_deltat(1960, 33.2, 0.10) test_deltat(1965, 35.7, 0.09) test_deltat(1970, 40.2, 0.05)
660c5e2014-12-06Marcus Comstedt test_deltat(1975, 45.5, 0.06)
ffc8602014-12-03Henrik Grubbström (Grubba) test_deltat(1980, 50.5, 0.05) test_deltat(1985, 54.3, 0.05) test_deltat(1990, 56.9, 0.05) test_deltat(1995, 60.8, 0.05) test_deltat(2000, 63.8, 0.08) test_deltat(2005, 64.7, 0.05)
1169d92004-05-02Martin Nilsson END_MARKER