int main(int argc, char *argv[]) { timelib_time *t; timelib_sll rise, set, transit; int rs, h, m, s; double h_rise, h_set; if (argc != 4) { printf("Usage: ./test-astro time longitude latitude\n ./test-astro \"2005-10-17 00:00:00\" 9.627 59.186\n"); return -1; } t = timelib_strtotime(argv[1] /*"2005-10-17 00:00:00"*/, strlen(argv[1]), NULL, timelib_builtin_db(), timelib_parse_tzfile); timelib_dump_date(t, 1); rs = timelib_astro_rise_set_altitude(t, atof(argv[2]) /*9.627*/, atof(argv[3]) /*59.186*/, 0, 0, &h_rise, &h_set, &rise, &set, &transit); switch (rs) { case 0: break; case +1: printf( "Sun always above horizon\n"); break; case -1: printf( "Sun always below horizon\n"); break; } timelib_unixtime2local(t, rise); timelib_dump_date(t, 1); timelib_decimal_hour_to_hms(h_rise, &h, &m, &s); timelib_unixtime2local(t, set); timelib_dump_date(t, 1); timelib_decimal_hour_to_hms(h_set, &h, &m, &s); if (t->tz_info) { timelib_tzinfo_dtor(t->tz_info); } timelib_time_dtor(t); return 0; }
TEST(issues, issue0019_test4) { timelib_sll ts = -12622953600; timelib_time *t = timelib_time_ctor(); timelib_set_timezone_from_offset(t, 0); timelib_unixtime2local(t, ts); LONGS_EQUAL(1569, t->y); LONGS_EQUAL(12, t->m); LONGS_EQUAL(30, t->d); timelib_time_dtor(t); }
TEST(issues, issue0019_test3) { timelib_sll ts = 0; timelib_time *t = timelib_time_ctor(); timelib_set_timezone_from_offset(t, 0); timelib_unixtime2local(t, ts); LONGS_EQUAL(1970, t->y); LONGS_EQUAL(1, t->m); LONGS_EQUAL(1, t->d); timelib_time_dtor(t); }
TEST(issues, issue0017_test1) { timelib_sll ts = 12622608000; timelib_time *t = timelib_time_ctor(); timelib_set_timezone_from_offset(t, 0); timelib_unixtime2local(t, ts); LONGS_EQUAL(2369, t->y); LONGS_EQUAL(12, t->m); LONGS_EQUAL(30, t->d); timelib_time_dtor(t); }
TEST(issues, issue0053_test3) { int dummy_error; timelib_tzinfo *tzi; timelib_sll ts = -1822500432; timelib_time *t = timelib_time_ctor(); tzi = timelib_parse_tzfile((char*) "America/Belize", timelib_builtin_db(), &dummy_error); t->tz_info = tzi; t->zone_type = TIMELIB_ZONETYPE_ID; timelib_unixtime2local(t, ts); LONGS_EQUAL(-21600, t->z); timelib_time_dtor(t); timelib_tzinfo_dtor(tzi); }
TEST(issues, issue0053_test1) { int dummy_error; timelib_tzinfo *tzi; timelib_sll ts = -61626506832; timelib_time *t = timelib_time_ctor(); tzi = timelib_parse_tzfile((char*) "America/Belize", timelib_builtin_db(), &dummy_error); t->tz_info = tzi; t->zone_type = TIMELIB_ZONETYPE_ID; timelib_unixtime2local(t, ts); LONGS_EQUAL(17, t->y); LONGS_EQUAL(2, t->m); LONGS_EQUAL(18, t->d); LONGS_EQUAL(0, t->h); LONGS_EQUAL(0, t->i); LONGS_EQUAL(0, t->s); LONGS_EQUAL(-21168, t->z); timelib_time_dtor(t); timelib_tzinfo_dtor(tzi); }