2010-07-01 19:48:07 -04:00
|
|
|
<?php
|
2016-02-03 13:48:09 -05:00
|
|
|
/**
|
|
|
|
* @file include/datetime.php
|
|
|
|
* @brief Some functions for date and time related tasks.
|
|
|
|
*/
|
2010-07-01 19:48:07 -04:00
|
|
|
|
2018-01-24 20:47:33 -05:00
|
|
|
use Friendica\Model\Contact;
|
|
|
|
use Friendica\Util\Temporal;
|
2010-09-27 03:38:26 -04:00
|
|
|
|
2010-07-01 19:48:07 -04:00
|
|
|
function select_timezone($current = 'America/Los_Angeles') {
|
2018-01-24 20:47:33 -05:00
|
|
|
return Temporal::getTimezoneSelect($current);
|
2016-02-03 13:48:09 -05:00
|
|
|
}
|
2010-07-01 19:48:07 -04:00
|
|
|
|
2018-01-24 20:47:33 -05:00
|
|
|
function field_timezone($name='timezone', $label='', $current = 'America/Los_Angeles', $help = ''){
|
|
|
|
return Temporal::getTimezoneField($name, $label, $current, $help);
|
2016-02-03 13:48:09 -05:00
|
|
|
}
|
2010-07-01 19:48:07 -04:00
|
|
|
|
|
|
|
function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d H:i:s") {
|
2018-01-24 20:47:33 -05:00
|
|
|
return Temporal::convert($s, $to, $from, $fmt);
|
2016-02-03 13:48:09 -05:00
|
|
|
}
|
2012-07-16 00:00:11 -04:00
|
|
|
|
2018-01-24 20:47:33 -05:00
|
|
|
function dob($dob) {
|
|
|
|
return Temporal::getDateofBirthField($dob);
|
2011-07-25 23:59:25 -04:00
|
|
|
}
|
|
|
|
|
2018-01-24 20:47:33 -05:00
|
|
|
function datesel($min, $max, $default, $id = 'datepicker') {
|
|
|
|
return Temporal::getDateField($min, $max, $default, $id);
|
2016-02-03 13:48:09 -05:00
|
|
|
}
|
2010-07-01 19:48:07 -04:00
|
|
|
|
2018-01-24 20:47:33 -05:00
|
|
|
function timesel($h, $m, $id = 'timepicker') {
|
|
|
|
return Temporal::getTimeField($h, $m, $id);
|
2016-02-03 13:48:09 -05:00
|
|
|
}
|
2011-06-06 22:59:20 -04:00
|
|
|
|
2018-01-24 20:47:33 -05:00
|
|
|
function datetimesel($min, $max, $default, $label, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false) {
|
|
|
|
return Temporal::getDateTimeField($min, $max, $default, $label, $id, $pickdate, $picktime, $minfrom, $maxfrom, $required);
|
2016-02-03 13:48:09 -05:00
|
|
|
}
|
2010-07-01 19:48:07 -04:00
|
|
|
|
2016-10-28 05:54:26 -04:00
|
|
|
function relative_date($posted_date, $format = null) {
|
2018-01-24 20:47:33 -05:00
|
|
|
return Temporal::getRelativeDate($posted_date, $format);
|
2016-02-03 13:48:09 -05:00
|
|
|
}
|
2010-09-27 03:38:26 -04:00
|
|
|
|
2017-04-04 13:47:32 -04:00
|
|
|
function age($dob, $owner_tz = '', $viewer_tz = '') {
|
2018-01-24 20:47:33 -05:00
|
|
|
return Temporal::getAgeByTimezone($dob, $owner_tz, $viewer_tz);
|
2010-07-10 01:47:32 -04:00
|
|
|
}
|
2011-02-22 23:08:15 -05:00
|
|
|
|
2017-04-04 13:47:32 -04:00
|
|
|
function get_dim($y, $m) {
|
2018-01-24 20:47:33 -05:00
|
|
|
return Temporal::getDaysInMonth($y, $m);
|
2016-02-03 13:48:09 -05:00
|
|
|
}
|
2011-02-22 23:08:15 -05:00
|
|
|
|
2016-02-03 13:48:09 -05:00
|
|
|
function get_first_dim($y,$m) {
|
2018-01-24 20:47:33 -05:00
|
|
|
return Temporal::getFirstDayInMonth($y, $m);
|
2016-02-03 13:48:09 -05:00
|
|
|
}
|
2011-02-22 23:08:15 -05:00
|
|
|
|
2018-01-04 19:42:48 -05:00
|
|
|
function cal($y = 0, $m = 0, $links = null, $class = '')
|
|
|
|
{
|
2018-01-24 20:47:33 -05:00
|
|
|
return Temporal::getCalendarTable($y, $m, $links, $class);
|
2016-02-03 13:48:09 -05:00
|
|
|
}
|
|
|
|
|
2011-10-14 03:20:37 -04:00
|
|
|
function update_contact_birthdays() {
|
2018-01-24 20:47:33 -05:00
|
|
|
return Contact::updateBirthdays();
|
2012-01-02 14:09:25 -05:00
|
|
|
}
|