示例#1
0
bool TestExtDatetime::test_date_diff() {
  Object dt1 = f_date_create("2010-08-02");
  Object dt2 = f_date_create("2010-08-30");
  Object interval = f_date_diff(dt1, dt2, true);
  VS(f_date_interval_format(interval, "%d"), "28");
  return Count(true);
}
示例#2
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);
}
示例#3
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);
}
示例#4
0
bool TestExtDatetime::test_date_add() {
  Object datetime = f_date_create("2010-08-16");
  Object interval = f_date_interval_create_from_date_string("2 weeks");
  Object dt2 = f_date_add(datetime, interval);
  VDT(dt2, "2010-08-30 00:00:00");
  return Count(true);
}
示例#5
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);
}
示例#6
0
bool TestExtDatetime::test_date_sub() {
  Object datetime = f_date_create("2010-08-16");
  Object interval = f_date_interval_create_from_date_string("2 weeks");
  Object dt2 = f_date_sub(datetime, interval);
  VS(f_date_format(dt2, "Y-m-d"), "2010-08-02");
  return Count(true);
}
示例#7
0
bool TestExtDatetime::test_date_format() {
  Object dt = f_date_create("@1170288001");
  VS(f_date_format(dt, "Y-m-d\\TH:i:s\\Z"), "2007-02-01T00:00:01Z");
  VS(f_date_format(dt, "Y-m-dTH:i:sZ"), "2007-02-01PST00:00:01-28800");
  VS(DateTime(1255494072, true).toString(DateTime::Cookie),
     "Wed, 14-Oct-2009 04:21:12 GMT");
  return Count(true);
}
示例#8
0
bool TestExtDatetime::test_date_get_last_errors() {
  Object dt = f_date_create("asdfasdf");
  Array errs = f_date_get_last_errors();
  VS(errs.size(), 4);

  VS(errs["warning_count"], 1);
  Array err_warnings = errs["warnings"];
  VS(err_warnings.size(), 1);
  VS(err_warnings[6], "Double timezone specification");

  VS(errs["error_count"], 1);
  Array err_errors = errs["errors"];
  VS(err_errors.size(), 1);
  VS(err_errors[0], "The timezone could not be found in the database");

  return Count(true);
}
示例#9
0
bool TestExtDatetime::test_date_date_set() {
  Object dt = f_date_create("2006-12-12 12:34:56");
  f_date_date_set(dt, 2007, 11, 23);
  VDT(dt, "2007-11-23 12:34:56");
  return Count(true);
}
示例#10
0
bool TestExtDatetime::test_date_create() {
  VDT(f_date_create("2006-12-12"),  "2006-12-12 00:00:00");
  VDT(f_date_create("@1170288001"), "2007-02-01 00:00:01");
  return Count(true);
}
示例#11
0
bool TestExtDatetime::test_date_timezone_get() {
  Object dt = f_date_create("2008-08-08 12:34:56");
  VS(f_timezone_name_get(f_date_timezone_get(dt)), "America/Los_Angeles");
  return Count(true);
}
示例#12
0
bool TestExtDatetime::test_date_time_set() {
  Object dt = f_date_create("2006-12-12 12:34:56");
  f_date_time_set(dt, 23, 45, 12);
  VDT(dt, "2006-12-12 23:45:12");
  return Count(true);
}
示例#13
0
bool TestExtDatetime::test_date_offset_get() {
  VS(f_date_offset_get(f_date_create("2006-12-12")), -28800);
  VS(f_date_offset_get(f_date_create("2008-08-08")), -25200);
  return Count(true);
}
示例#14
0
bool TestExtDatetime::test_date_modify() {
  Object dt = f_date_create("2006-12-12 00:00:00");
  f_date_modify(dt, "+1 day");
  VDT(dt, "2006-12-13 00:00:00");
  return Count(true);
}
示例#15
0
bool TestExtDatetime::test_date_isodate_set() {
  Object dt = f_date_create("2008-08-08 00:00:00");
  f_date_isodate_set(dt, 2007, 35, 3);
  VDT(dt, "2007-08-29 00:00:00");
  return Count(true);
}
示例#16
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);
}