2019-09-07 14:37:00 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function ensure($bool, $error_msg = "") {
|
|
|
|
if (!$bool)
|
|
|
|
throw new AssertionError($error_msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatDate($date = NULL, $with_time = false) {
|
|
|
|
if ($date == NULL)
|
|
|
|
$date = date("yyyy-mm-dd");
|
|
|
|
|
|
|
|
return strftime("%d %B %G" . ($with_time ? " %H:%M" : ""), strtotime($date));
|
|
|
|
}
|
|
|
|
|
2019-09-07 16:08:40 +00:00
|
|
|
function dateWellFormed($date, $with_time = false) {
|
|
|
|
return date_parse_from_format($with_time ? "yyyy-mm-dd HH-MM:ss" : "yy-mm-dd", $date) !== false;
|
2019-09-07 14:37:00 +00:00
|
|
|
}
|