Esempio n. 1
0
bool TestExtDatetime::test_timezone_offset_get() {
  // Create two timezone objects, one for Taipei (Taiwan) and one for
  // Tokyo (Japan)
  Object dateTimeZoneTaipei = f_timezone_open("Asia/Taipei");
  Object dateTimeZoneJapan = f_timezone_open("Asia/Tokyo");

  // Create two DateTime objects that will contain the same Unix timestamp, but
  // have different timezones attached to them.
  Object dateTimeTaipei = f_date_create("2008-08-08", dateTimeZoneTaipei);
  Object dateTimeJapan = f_date_create("2008-08-08", dateTimeZoneJapan);

  VS(f_date_offset_get(dateTimeTaipei), 28800);
  VS(f_date_offset_get(dateTimeJapan), 32400);

  return Count(true);
}
Esempio n. 2
0
bool TestExtDatetime::test_date_timezone_set() {
  Object dt = f_date_create("2008-08-08 12:34:56");
  f_date_timezone_set(dt, f_timezone_open("Asia/Shanghai"));
  VS(f_timezone_name_get(f_date_timezone_get(dt)), "Asia/Shanghai");
  VDT(dt, "2008-08-09 03:34:56");
  return Count(true);
}
Esempio n. 3
0
bool TestExtDatetime::test_date_timestamp_set() {
  Object tz = f_timezone_open("America/Los_Angeles");
  Object dt = f_date_create("2008-08-08 12:34:56", tz);
  f_date_timestamp_set(dt, 1000000000);
  VS(f_date_format(dt, "Y-m-d H:i:s"), "2001-09-08 18:46:40");
  return Count(true);
}
Esempio n. 4
0
bool TestExtDatetime::test_timezone_transitions_get() {
  Object timezone = f_timezone_open("CET");
  Array transitions = f_timezone_transitions_get(timezone);
  VS(transitions[0]["ts"], -1693706400);
  VS(transitions[0]["offset"], 7200);
  VS(transitions[0]["isdst"], true);
  VS(transitions[0]["abbr"], "CEST");
  return Count(true);
}
Esempio n. 5
0
bool TestExtDatetime::test_timezone_location_get() {
  Object tz = f_timezone_open("Europe/Prague");
  Array loc = f_timezone_location_get(tz);
  VS(loc.size(), 4);
  VS(loc["country_code"].toString(), "CZ");
  VS((int)(loc["latitude"].toDoubleVal() * 100), 5008);
  VS((int)(loc["longitude"].toDoubleVal() * 100), 1443);
  VS(loc["comments"].toString(), "");
  return Count(true);
}
Esempio n. 6
0
bool TestExtDatetime::test_timezone_open() {
  Object tz = f_timezone_open("Asia/Shanghai");
  VS(f_timezone_name_get(tz), "Asia/Shanghai");
  return Count(true);
}
Esempio n. 7
0
bool TestExtDatetime::test_date_timestamp_get() {
  Object tz = f_timezone_open("America/Los_Angeles");
  Object dt = f_date_create("2008-08-08 12:34:56", tz);
  VS(f_date_timestamp_get(dt), 1218224096);
  return Count(true);
}