diff --git a/www/admin/class_test.datetime.php b/www/admin/class_test.datetime.php
index a20fb41c..7255c368 100644
--- a/www/admin/class_test.datetime.php
+++ b/www/admin/class_test.datetime.php
@@ -51,10 +51,7 @@ if (round($timestamp, 4) == DateTime::stringToTime($time_string)) {
} else {
print "REVERSE TRIME STRING DO NOT MATCH
";
}
-print "ZERO TIME STRING: " . DateTime::timeStringFormat(0, true) . "
";
-print "ZERO TIME STRING: " . DateTime::timeStringFormat(0.0, true) . "
";
-print "ZERO TIME STRING: " . DateTime::timeStringFormat(1.005, true) . "
";
-
+print "
";
$timestamps = [
1622788315.123456,
-1622788315.456789
@@ -64,6 +61,159 @@ foreach ($timestamps as $timestamp) {
print "DATESTRINGFORMAT(sm:1:0): $timestamp: " . DateTime::dateStringFormat($timestamp, true) . "
";
print "DATESTRINGFORMAT(sm:1:1): $timestamp: " . DateTime::dateStringFormat($timestamp, true, true) . "
";
}
+print "
";
+// $interval = 0;
+// $interval = 1000000;
+// $interval = 123456;
+// $interval = 3600;
+$interval = 3601;
+// $interval = 86400;
+// $interval = 86401;
+// $interval = (86400 * 606) + 16434.5;
+// $interval = 1.5;
+// $interval = 123456;
+// $interval = 120.1;
+// $interval = 1641515890;
+// $interval = 0.123456;
+// $interval = 1641515890;
+// $interval = 999999999999999999;
+// $interval = 60;
+try {
+ // print "Test-DEP: [$interval] "
+ // . intervalStringFormatDeprecated(
+ // $interval,
+ // truncate_after: '',
+ // natural_seperator: false,
+ // name_space_seperator: false,
+ // show_microseconds: true,
+ // short_time_name: true,
+ // skip_last_zero: true,
+ // skip_zero: false,
+ // show_only_days: false,
+ // auto_fix_microseconds: false,
+ // truncate_nanoseconds: false,
+ // truncate_zero_seconds_if_microseconds: true,
+ // )
+ // // . " => "
+ // // . DateTime::intervalStringFormat($interval)
+ // . "
";
+ print "Test-ACT: [$interval] "
+ . DateTime::intervalStringFormat(
+ $interval,
+ truncate_after: '',
+ natural_seperator: false,
+ name_space_seperator: false,
+ show_microseconds: true,
+ short_time_name: true,
+ skip_last_zero: true,
+ skip_zero: false,
+ show_only_days: false,
+ auto_fix_microseconds: false,
+ truncate_nanoseconds: false,
+ truncate_zero_seconds_if_microseconds: true,
+ )
+ . " => "
+ . DateTime::intervalStringFormat($interval)
+ . "
";
+ print "DEFAULT-DEP: " . intervalStringFormatDeprecated($interval) . "
";
+ print "DEFAULT-ACT: " . DateTime::intervalStringFormat($interval) . "
";
+ $show_micro = true;
+ // print "COMPATIBLE Test-DEP: " .
+ // intervalStringFormatDeprecated(
+ // $interval,
+ // show_microseconds: $show_micro,
+ // show_only_days: true,
+ // skip_zero: false,
+ // skip_last_zero: false,
+ // truncate_nanoseconds: true,
+ // truncate_zero_seconds_if_microseconds: false
+ // ) . "
";
+ print "COMPATIBLE Test-ACT: " .
+ DateTime::intervalStringFormat(
+ $interval,
+ show_microseconds: $show_micro,
+ show_only_days: true,
+ skip_zero: false,
+ skip_last_zero: false,
+ truncate_nanoseconds: true,
+ truncate_zero_seconds_if_microseconds: false
+ ) . "
";
+ print "ORIGINAL: " . DateTime::timeStringFormat($interval, $show_micro) . "
";
+} catch (\UnexpectedValueException $e) {
+ print "ERROR: " . $e->getMessage() . "
" . $e . "
";
+} catch (\LengthException $e) {
+ print "ERROR interval: " . $e->getMessage() . "
" . $e . "
";
+}
+print "
";
+$intervals = [
+ ['i' => 0, 'sm' => true],
+ ['i' => 0.0, 'sm' => true],
+ ['i' => 1.5, 'sm' => true],
+ ['i' => 1.05, 'sm' => true],
+ ['i' => 1.005, 'sm' => true],
+ ['i' => 1.0005, 'sm' => true],
+];
+foreach ($intervals as $int) {
+ $info = 'ts:' . $int['i'] . '|' . 'sm:' . $int['sm'];
+ print "[tsf] ZERO TIME STRING [$info]: "
+ . DateTime::timeStringFormat($int['i'], $int['sm']) . "
";
+ print "[isf] ZERO TIME STRING [$info]: "
+ . DateTime::intervalStringFormat($int['i'], show_microseconds:$int['sm']) . "
";
+}
+print "
";
+$intervals = [
+ [
+ 'i' => 788315.123456,
+ 'truncate_after' => '',
+ 'natural_seperator' => false,
+ 'name_space_seperator' => false,
+ 'show_microseconds' => true,
+ 'short_time_name' => true,
+ 'skip_last_zero' => false,
+ 'skip_zero' => true,
+ 'show_only_days' => false,
+ 'auto_fix_microseconds' => false,
+ 'truncate_nanoseconds' => false
+ ],
+ [
+ 'i' => 788315.123456,
+ 'truncate_after' => '',
+ 'natural_seperator' => true,
+ 'name_space_seperator' => true,
+ 'show_microseconds' => true,
+ 'short_time_name' => true,
+ 'skip_last_zero' => false,
+ 'skip_zero' => true,
+ 'show_only_days' => false,
+ 'auto_fix_microseconds' => false,
+ 'truncate_nanoseconds' => false
+ ],
+];
+foreach ($intervals as $int) {
+ $info = $int['i'];
+ try {
+ print "INTRVALSTRINGFORMAT(sm:0): $info: "
+ . DateTime::intervalStringFormat(
+ $int['i'],
+ truncate_after: (string)$int['truncate_after'],
+ natural_seperator: $int['natural_seperator'],
+ name_space_seperator: $int['name_space_seperator'],
+ show_microseconds: $int['show_microseconds'],
+ short_time_name: $int['short_time_name'],
+ skip_last_zero: $int['skip_last_zero'],
+ skip_zero: $int['skip_zero'],
+ show_only_days: $int['show_only_days'],
+ auto_fix_microseconds: $int['auto_fix_microseconds'],
+ truncate_nanoseconds: $int['truncate_nanoseconds'],
+ ) . "
";
+ } catch (\UnexpectedValueException $e) {
+ print "ERROR: " . $e->getMessage() . "
" . $e . "
";
+ } catch (\LengthException $e) {
+ print "ERROR interval: " . $e->getMessage() . "
" . $e . "
";
+ }
+}
+print "
";
+// convert and reverste tests
$intervals = [
788315.123456,
-123.456
@@ -74,6 +224,7 @@ foreach ($intervals as $interval) {
print "TIMESTRINGFORMAT(sm:1): $interval: " . $reverse_interval . "
";
print "STRINGTOTIME: $reverse_interval: " . DateTime::stringToTime($reverse_interval) . "
";
}
+print "
";
$check_dates = [
'2021-05-01',
'2021-05-40'
@@ -81,6 +232,7 @@ $check_dates = [
foreach ($check_dates as $check_date) {
print "CHECKDATE: $check_date: " . (string)DateTime::checkDate($check_date) . "
";
}
+print "
";
$check_datetimes = [
'2021-05-01',
'2021-05-40',
@@ -91,6 +243,7 @@ $check_datetimes = [
foreach ($check_datetimes as $check_datetime) {
print "CHECKDATETIME: $check_datetime: " . (string)DateTime::checkDateTime($check_datetime) . "
";
}
+print "
";
$compare_dates = [
[ '2021-05-01', '2021-05-02', ],
[ '2021-05-02', '2021-05-01', ],
@@ -102,6 +255,7 @@ foreach ($compare_dates as $compare_date) {
print "COMPAREDATE: $compare_date[0] = $compare_date[1]: "
. (string)DateTime::compareDate($compare_date[0], $compare_date[1]) . "
";
}
+print "
";
$compare_datetimes = [
[ '2021-05-01', '2021-05-02', ],
[ '2021-05-02', '2021-05-01', ],
@@ -114,6 +268,7 @@ foreach ($compare_datetimes as $compare_datetime) {
print "COMPAREDATE: $compare_datetime[0] = $compare_datetime[1]: "
. (string)DateTime::compareDateTime($compare_datetime[0], $compare_datetime[1]) . "
";
}
+print "
";
$compare_dates = [
[ '2021-05-01', '2021-05-10', ],
[ '2021-05-10', '2021-05-01', ],
@@ -126,7 +281,7 @@ foreach ($compare_dates as $compare_date) {
print "CALCDAYSINTERVAL(named): $compare_date[0] = $compare_date[1]: "
. DgS::printAr(DateTime::calcDaysInterval($compare_date[0], $compare_date[1], true)) . "
";
}
-
+print "
";
// test date conversion
$dow = 2;
print "DOW[$dow]: " . DateTime::setWeekdayNameFromIsoDow($dow) . "
";
@@ -142,7 +297,7 @@ $date = '2022-70-242';
print "DATE-dow[$date];invalid: " . DateTime::setWeekdayNameFromDate($date) . "
";
print "DATE-dow[$date],long;invalid: " . DateTime::setWeekdayNameFromDate($date, true) . "
";
print "DOW-date[$date];invalid: " . DateTime::setWeekdayNumberFromDate($date) . "
";
-
+print "
";
// check date range includes a weekend
// does not:
$start_date = '2023-07-03';
@@ -165,4 +320,237 @@ print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
print "