From b24690e8df43b9db055fc67b5c306daf23d8ec56 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 24 Jan 2018 21:29:09 -0500 Subject: [PATCH 1/6] Refactor datetime_convert() into Temporal::convert() --- ...v_caldav_backend_virtual_friendica.inc.php | 9 ++++---- dwpost/dwpost.php | 4 +++- fromgplus/fromgplus.php | 5 ++-- ijpost/ijpost.php | 4 +++- ljpost/ljpost.php | 4 +++- membersince/membersince.php | 6 +++-- public_server/public_server.php | 12 ++++++---- pumpio/pumpio.php | 18 ++++++++------- statusnet/statusnet.php | 21 +++++++++-------- testdrive/testdrive.php | 6 +++-- twitter/twitter.php | 23 ++++++++++--------- 11 files changed, 66 insertions(+), 46 deletions(-) diff --git a/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php index 718d952d..405bbb19 100644 --- a/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php +++ b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php @@ -1,6 +1,7 @@ */ + use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Util\Network; +use Friendica\Util\Temporal; function dwpost_install() { Addon::registerHook('post_local', 'addon/dwpost/dwpost.php', 'dwpost_post_local'); @@ -185,7 +187,7 @@ function dwpost_send(&$a,&$b) { $post = xmlify($post); $tags = dwpost_get_tags($b['tag']); - $date = datetime_convert('UTC',$tz,$b['created'],'Y-m-d H:i:s'); + $date = Temporal::convert($b['created'], $tz); $year = intval(substr($date,0,4)); $mon = intval(substr($date,5,2)); $day = intval(substr($date,8,2)); diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index 0a2b6802..fa6c0e39 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -15,6 +15,7 @@ use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Object\Image; use Friendica\Util\Network; +use Friendica\Util\Temporal; require_once 'mod/share.php'; require_once 'mod/parse_url.php'; @@ -519,12 +520,12 @@ function fromgplus_fetch($a, $uid) { if (function_exists("share_header")) $post .= share_header($item->object->actor->displayName, $item->object->actor->url, $item->object->actor->image->url, "", - datetime_convert('UTC','UTC',$item->object->published),$item->object->url); + Temporal::convert($item->object->published),$item->object->url); else $post .= "[share author='".str_replace("'", "'",$item->object->actor->displayName). "' profile='".$item->object->actor->url. "' avatar='".$item->object->actor->image->url. - "' posted='".datetime_convert('UTC','UTC',$item->object->published). + "' posted='".Temporal::convert($item->object->published). "' link='".$item->object->url."']"; $post .= fromgplus_html2bbcode($item->object->content); diff --git a/ijpost/ijpost.php b/ijpost/ijpost.php index 9d9f9112..3c4e917d 100644 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@ -7,10 +7,12 @@ * Author: Michael Johnston * Author: Cat Gray */ + use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Util\Network; +use Friendica\Util\Temporal; function ijpost_install() { Addon::registerHook('post_local', 'addon/ijpost/ijpost.php', 'ijpost_post_local'); @@ -184,7 +186,7 @@ function ijpost_send(&$a,&$b) { $post = xmlify($post); $tags = ijpost_get_tags($b['tag']); - $date = datetime_convert('UTC',$tz,$b['created'],'Y-m-d H:i:s'); + $date = Temporal::convert($b['created'], $tz); $year = intval(substr($date,0,4)); $mon = intval(substr($date,5,2)); $day = intval(substr($date,8,2)); diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index 981162e8..ff89e5e6 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -7,10 +7,12 @@ * Author: Michael Johnston * Author: Cat Gray */ + use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Util\Network; +use Friendica\Util\Temporal; function ljpost_install() { Addon::registerHook('post_local', 'addon/ljpost/ljpost.php', 'ljpost_post_local'); @@ -185,7 +187,7 @@ function ljpost_send(&$a,&$b) { $post = xmlify($post); $tags = ljpost_get_tags($b['tag']); - $date = datetime_convert('UTC',$tz,$b['created'],'Y-m-d H:i:s'); + $date = Temporal::convert($b['created'], $tz); $year = intval(substr($date,0,4)); $mon = intval(substr($date,5,2)); $day = intval(substr($date,8,2)); diff --git a/membersince/membersince.php b/membersince/membersince.php index f1f135e9..b8bbca49 100644 --- a/membersince/membersince.php +++ b/membersince/membersince.php @@ -6,8 +6,10 @@ * Author: Mike Macgirvin * */ + use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Util\Temporal; require_once 'include/datetime.php'; @@ -24,8 +26,8 @@ function membersince_uninstall() function membersince_display(&$a, &$b) { // Works in Vier - $b = preg_replace('/<\/dl>/', "\n\n\n
\n
" . L10n::t('Member since:') . "
\n
" . datetime_convert('UTC', date_default_timezone_get(), $a->profile['register_date']) . "
\n
", $b, 1); + $b = preg_replace('/<\/dl>/', "\n\n\n
\n
" . L10n::t('Member since:') . "
\n
" . Temporal::convert($a->profile['register_date'], date_default_timezone_get()) . "
\n
", $b, 1); // Trying for Frio - //$b = preg_replace('/<\/div>/', "

" . L10n::t('Member since:') . "
" . datetime_convert('UTC', date_default_timezone_get(), $a->profile['register_date']) . "
", $b, 1); + //$b = preg_replace('/<\/div>/', "

" . L10n::t('Member since:') . "
" . Temporal::convert($a->profile['register_date'], date_default_timezone_get()) . "
", $b, 1); } diff --git a/public_server/public_server.php b/public_server/public_server.php index d3309e6e..52c115a3 100644 --- a/public_server/public_server.php +++ b/public_server/public_server.php @@ -5,10 +5,12 @@ * Version: 1.1 * Author: Keith Fernie */ + use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Model\User; +use Friendica\Util\Temporal; function public_server_install() { @@ -37,7 +39,7 @@ function public_server_register_account($a,$b) { return; $r = q("UPDATE user set account_expires_on = '%s', expire = %d where uid = %d", - dbesc(datetime_convert('UTC','UTC','now +' . $days . ' days')), + dbesc(Temporal::convert('now +' . $days . ' days')), intval($days_posts), intval($uid) ); @@ -67,7 +69,7 @@ function public_server_cron($a,$b) { ]); q("update user set expire_notification_sent = '%s' where uid = %d", - dbesc(datetime_convert()), + dbesc(Temporal::convert()), intval($rr['uid']) ); } @@ -85,7 +87,7 @@ function public_server_cron($a,$b) { if(count($r)) { foreach($r as $rr) q("update user set account_expires_on = '%s' where uid = %d", - dbesc(datetime_convert('UTC','UTC','now +' . '6 days')), + dbesc(Temporal::convert('now +' . '6 days')), intval($rr['uid']) ); } @@ -98,7 +100,7 @@ function public_server_cron($a,$b) { if(count($r)) { foreach($r as $rr) q("update user set account_expires_on = '%s' where uid = %d", - dbesc(datetime_convert('UTC','UTC','now +' . '6 days')), + dbesc(Temporal::convert('now +' . '6 days')), intval($rr['uid']) ); } @@ -136,7 +138,7 @@ function public_server_login($a,$b) { if(! $days) return; $r = q("UPDATE user set account_expires_on = '%s' where uid = %d and account_expires_on > '0000-00-00 00:00:00'", - dbesc(datetime_convert('UTC','UTC','now +' . $days . ' days')), + dbesc(Temporal::convert('now +' . $days . ' days')), local_user() ); } diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 970bbf09..bdc56795 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -5,6 +5,7 @@ * Version: 0.2 * Author: Michael Vogel */ + use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -13,10 +14,11 @@ use Friendica\Core\Worker; use Friendica\Model\Contact; use Friendica\Model\GContact; use Friendica\Model\Group; -use Friendica\Model\User; use Friendica\Model\Item; use Friendica\Model\Queue; use Friendica\Util\Network; +use Friendica\Model\User; +use Friendica\Util\Temporal; require 'addon/pumpio/oauth/http.php'; require 'addon/pumpio/oauth/oauth_client.php'; @@ -869,7 +871,7 @@ function pumpio_dounlike(&$a, $uid, $self, $post, $own_id) { } $r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `verb` = '%s' AND `uid` = %d AND `contact-id` = %d AND `thr-parent` = '%s'", - dbesc(datetime_convert()), + dbesc(Temporal::convert()), dbesc(ACTIVITY_LIKE), intval($uid), intval($contactid), @@ -1000,7 +1002,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) { `location`, `about`, `writable`, `blocked`, `readonly`, `pending` ) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0)", intval($uid), - dbesc(datetime_convert()), + dbesc(Temporal::convert()), dbesc($contact->url), dbesc(normalise_link($contact->url)), dbesc(str_replace("acct:", "", $contact->id)), @@ -1209,11 +1211,11 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet if ($post->object->displayName != "") $postarray['title'] = $post->object->displayName; - $postarray['created'] = datetime_convert('UTC','UTC',$post->published); + $postarray['created'] = Temporal::convert($post->published); if (isset($post->updated)) - $postarray['edited'] = datetime_convert('UTC','UTC',$post->updated); + $postarray['edited'] = Temporal::convert($post->updated); elseif (isset($post->received)) - $postarray['edited'] = datetime_convert('UTC','UTC',$post->received); + $postarray['edited'] = Temporal::convert($post->received); else $postarray['edited'] = $postarray['created']; @@ -1228,7 +1230,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet $postarray['body'] = share_header($share_author, $post->object->author->url, $post->object->author->image->url, "", - datetime_convert('UTC','UTC',$post->object->created), + Temporal::convert($post->object->created), $post->links->self->href). $postarray['body']."[/share]"; @@ -1236,7 +1238,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet $postarray['body'] = "[share author='".$share_author. "' profile='".$post->object->author->url. "' avatar='".$post->object->author->image->url. - "' posted='".datetime_convert('UTC','UTC',$post->object->created). + "' posted='".Temporal::convert($post->object->created, 'UTC', 'UTC', ). "' link='".$post->links->self->href."']".$postarray['body']."[/share]"; */ } else { diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index d4d74f49..57095412 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -38,6 +38,8 @@ define('STATUSNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'statusnetoauth.php'; require_once 'include/enotify.php'; +use Codebird\Codebird; +use CodebirdSN\CodebirdSN; use Friendica\App; use Friendica\Content\OEmbed; use Friendica\Content\Text\BBCode; @@ -52,6 +54,7 @@ use Friendica\Model\Item; use Friendica\Model\Photo; use Friendica\Model\User; use Friendica\Util\Network; +use Friendica\Util\Temporal; function statusnet_install() { @@ -933,7 +936,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) `location`, `about`, `writable`, `blocked`, `readonly`, `pending` ) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0 ) ", intval($uid), - dbesc(datetime_convert()), + dbesc(Temporal::convert()), dbesc($contact->statusnet_profile_url), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(statusnet_address($contact)), @@ -974,13 +977,13 @@ function statusnet_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(datetime_convert()), + dbesc(Temporal::convert()), intval($contact_id) ); } else { // update profile photos once every two weeks as we have no notification of when they change. - //$update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -2 days')) ? true : false); - $update_photo = ($r[0]['avatar-date'] < datetime_convert('', '', 'now -12 hours')); + //$update_photo = (($r[0]['avatar-date'] < Temporal::convert('now -2 days', '', '', )) ? true : false); + $update_photo = ($r[0]['avatar-date'] < Temporal::convert('now -12 hours')); // check that we have all the photos, this has been known to fail on occasion if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) { @@ -1005,9 +1008,9 @@ function statusnet_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()), + dbesc(Temporal::convert()), + dbesc(Temporal::convert()), + dbesc(Temporal::convert()), dbesc($contact->statusnet_profile_url), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(statusnet_address($contact)), @@ -1194,8 +1197,8 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex $postarray['body'] = $converted["body"]; $postarray['tag'] = $converted["tags"]; - $postarray['created'] = datetime_convert('UTC', 'UTC', $content->created_at); - $postarray['edited'] = datetime_convert('UTC', 'UTC', $content->created_at); + $postarray['created'] = Temporal::convert($content->created_at); + $postarray['edited'] = Temporal::convert($content->created_at); if (is_string($content->place->name)) { $postarray["location"] = $content->place->name; diff --git a/testdrive/testdrive.php b/testdrive/testdrive.php index 87c6de33..efff8c28 100644 --- a/testdrive/testdrive.php +++ b/testdrive/testdrive.php @@ -5,10 +5,12 @@ * Version: 1.0 * Author: Mike Macgirvin */ + use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Model\User; +use Friendica\Util\Temporal; function testdrive_install() { @@ -42,7 +44,7 @@ function testdrive_register_account($a,$b) { return; $r = q("UPDATE user set account_expires_on = '%s' where uid = %d", - dbesc(datetime_convert('UTC','UTC','now +' . $days . ' days')), + dbesc(Temporal::convert('now +' . $days . ' days')), intval($uid) ); @@ -70,7 +72,7 @@ function testdrive_cron($a,$b) { ]); q("update user set expire_notification_sent = '%s' where uid = %d", - dbesc(datetime_convert()), + dbesc(Temporal::convert()), intval($rr['uid']) ); diff --git a/twitter/twitter.php b/twitter/twitter.php index 1863b8bc..d6d0ba7b 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -78,6 +78,7 @@ use Friendica\Model\Queue; use Friendica\Model\User; use Friendica\Object\Image; use Friendica\Util\Network; +use Friendica\Util\Temporal; require_once 'boot.php'; require_once 'include/dba.php'; @@ -1016,7 +1017,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) `location`, `about`, `writable`, `blocked`, `readonly`, `pending`) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0)", intval($uid), - dbesc(datetime_convert()), + dbesc(Temporal::convert()), dbesc("https://twitter.com/" . $contact->screen_name), dbesc(normalise_link("https://twitter.com/" . $contact->screen_name)), dbesc($contact->screen_name."@twitter.com"), @@ -1060,16 +1061,16 @@ function twitter_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()), + dbesc(Temporal::convert()), + dbesc(Temporal::convert()), + dbesc(Temporal::convert()), intval($contact_id) ); } } else { // update profile photos once every two weeks as we have no notification of when they change. - //$update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -2 days')) ? true : false); - $update_photo = ($r[0]['avatar-date'] < datetime_convert('', '', 'now -12 hours')); + //$update_photo = (($r[0]['avatar-date'] < Temporal::convert('now -2 days', '', '', )) ? true : false); + $update_photo = ($r[0]['avatar-date'] < Temporal::convert('now -12 hours')); // check that we have all the photos, this has been known to fail on occasion if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) { @@ -1095,9 +1096,9 @@ function twitter_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()), + dbesc(Temporal::convert()), + dbesc(Temporal::convert()), + dbesc(Temporal::convert()), dbesc("https://twitter.com/".$contact->screen_name), dbesc(normalise_link("https://twitter.com/".$contact->screen_name)), dbesc($contact->screen_name."@twitter.com"), @@ -1489,8 +1490,8 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis $converted = twitter_expand_entities($a, $postarray['body'], $post, false, $picture); $postarray['body'] = $converted["body"]; $postarray['tag'] = $converted["tags"]; - $postarray['created'] = datetime_convert('UTC', 'UTC', $post->created_at); - $postarray['edited'] = datetime_convert('UTC', 'UTC', $post->created_at); + $postarray['created'] = Temporal::convert($post->created_at); + $postarray['edited'] = Temporal::convert($post->created_at); $statustext = $converted["plain"]; From 6d23de1bdb6b53226006fa3d35849d45bc6bfec4 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 25 Jan 2018 22:00:29 -0500 Subject: [PATCH 2/6] Add Temporal::MYSQL constant --- dav/common/calendar.fnk.php | 5 +++-- dav/common/calendar_rendering.fnk.php | 7 ++++--- dav/common/wdcal_backend.inc.php | 9 +++++---- dav/common/wdcal_edit.inc.php | 9 +++++---- .../dav_caldav_backend_virtual_friendica.inc.php | 8 ++++---- pumpio/pumpio.php | 2 +- statusnet/statusnet.php | 2 +- twitter/twitter.php | 2 +- 8 files changed, 24 insertions(+), 20 deletions(-) diff --git a/dav/common/calendar.fnk.php b/dav/common/calendar.fnk.php index 11f31f7d..1245ee2e 100644 --- a/dav/common/calendar.fnk.php +++ b/dav/common/calendar.fnk.php @@ -1,5 +1,6 @@ format("U"); } diff --git a/dav/common/calendar_rendering.fnk.php b/dav/common/calendar_rendering.fnk.php index d80892f7..ae6e39dd 100644 --- a/dav/common/calendar_rendering.fnk.php +++ b/dav/common/calendar_rendering.fnk.php @@ -1,5 +1,6 @@ getTimestamp() < time() ? 1 : 0); q("INSERT INTO %s%snotifications (`calendar_id`, `calendarobject_id`, `alert_date`, `notified`) VALUES (%d, %d, CONVERT_TZ('%s', '$timezoneOffset', @@session.time_zone), %d)", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($calendar["id"]), IntVal($calendarobject["id"]), $alarm->format("Y-m-d H:i:s"), $notified + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($calendar["id"]), IntVal($calendarobject["id"]), $alarm->format(Temporal::MYSQL), $notified ); } diff --git a/dav/common/wdcal_backend.inc.php b/dav/common/wdcal_backend.inc.php index a3e18eb3..5418c90a 100644 --- a/dav/common/wdcal_backend.inc.php +++ b/dav/common/wdcal_backend.inc.php @@ -1,6 +1,7 @@ setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarStartTime"]))), $type); + $datetime_start->setDateTime(new DateTime(date(Temporal::MYSQL, IntVal($_REQUEST["CalendarStartTime"]))), $type); $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); - $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarEndTime"]))), $type); + $datetime_end->setDateTime(new DateTime(date(Temporal::MYSQL, IntVal($_REQUEST["CalendarEndTime"]))), $type); $component->add($datetime_start); $component->add($datetime_end); @@ -182,9 +183,9 @@ function wdcal_print_feed($base_path = "") else $type = Sabre\VObject\Property\DateTime::LOCALTZ; $datetime_start = new Sabre\VObject\Property\DateTime("DTSTART"); - $datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarStartTime"]))), $type); + $datetime_start->setDateTime(new DateTime(date(Temporal::MYSQL, IntVal($_REQUEST["CalendarStartTime"]))), $type); $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); - $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarEndTime"]))), $type); + $datetime_end->setDateTime(new DateTime(date(Temporal::MYSQL, IntVal($_REQUEST["CalendarEndTime"]))), $type); $component->__unset("DTSTART"); $component->__unset("DTEND"); diff --git a/dav/common/wdcal_edit.inc.php b/dav/common/wdcal_edit.inc.php index f4ac90c9..8154a68b 100644 --- a/dav/common/wdcal_edit.inc.php +++ b/dav/common/wdcal_edit.inc.php @@ -1,6 +1,7 @@ setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_start)), $type); + $datetime_start->setDateTime(new DateTime(date(Temporal::MYSQL, $ts_start)), $type); $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); - $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_end)), $type); + $datetime_end->setDateTime(new DateTime(date(Temporal::MYSQL, $ts_end)), $type); $component->__unset("DTSTART"); $component->__unset("DTEND"); @@ -598,7 +599,7 @@ function wdcal_set_component_recurrence(&$component, &$localization) $date = $localization->date_local2timestamp($_REQUEST["rec_until_date"]); $part_until = ";UNTIL=" . date("Ymd", $date); $datetime_until = new Sabre\VObject\Property\DateTime("UNTIL"); - $datetime_until->setDateTime(new DateTime(date("Y-m-d H:i:s", $date)), Sabre\VObject\Property\DateTime::DATE); + $datetime_until->setDateTime(new DateTime(date(Temporal::MYSQL, $date)), Sabre\VObject\Property\DateTime::DATE); break; case "count": $part_until = ";COUNT=" . IntVal($_REQUEST["rec_until_count"]); @@ -645,7 +646,7 @@ function wdcal_set_component_recurrence(&$component, &$localization) if (isset($_REQUEST["rec_exceptions"])) { $arr = array(); foreach ($_REQUEST["rec_exceptions"] as $except) { - $arr[] = new DateTime(date("Y-m-d H:i:s", $except)); + $arr[] = new DateTime(date(Temporal::MYSQL, $except)); } /** @var Sabre\VObject\Property\MultiDateTime $prop */ $prop = Sabre\VObject\Property::create("EXDATE"); diff --git a/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php index 405bbb19..3baaa10c 100644 --- a/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php +++ b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php @@ -88,9 +88,9 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual $type = ($allday ? Sabre\VObject\Property\DateTime::DATE : Sabre\VObject\Property\DateTime::LOCALTZ); $datetime_start = new Sabre\VObject\Property\DateTime("DTSTART"); - $datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_start)), $type); + $datetime_start->setDateTime(new DateTime(date(Temporal::MYSQL, $ts_start)), $type); $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); - $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_end)), $type); + $datetime_end->setDateTime(new DateTime(date(Temporal::MYSQL, $ts_end)), $type); $component->add($datetime_start); $component->add($datetime_end); @@ -175,11 +175,11 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual } if ($date_from != "") { - if (is_numeric($date_from)) $sql_where .= " AND `finish` >= '" . date("Y-m-d H:i:s", $date_from) . "'"; + if (is_numeric($date_from)) $sql_where .= " AND `finish` >= '" . date(Temporal::MYSQL, $date_from) . "'"; else $sql_where .= " AND `finish` >= '" . dbesc($date_from) . "'"; } if ($date_to != "") { - if (is_numeric($date_to)) $sql_where .= " AND `start` <= '" . date("Y-m-d H:i:s", $date_to) . "'"; + if (is_numeric($date_to)) $sql_where .= " AND `start` <= '" . date(Temporal::MYSQL, $date_to) . "'"; else $sql_where .= " AND `start` <= '" . dbesc($date_to) . "'"; } $ret = []; diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index bdc56795..7e34eab3 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -672,7 +672,7 @@ function pumpio_sync(&$a) { if ($abandon_days < 1) $abandon_days = 0; - $abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400); + $abandon_limit = date(Temporal::MYSQL, time() - $abandon_days * 86400); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'import' AND `v` = '1' ORDER BY RAND() "); if(count($r)) { diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 57095412..c5b62a5d 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -760,7 +760,7 @@ function statusnet_cron(App $a, $b) $abandon_days = 0; } - $abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400); + $abandon_limit = date(Temporal::MYSQL, time() - $abandon_days * 86400); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()"); if (count($r)) { diff --git a/twitter/twitter.php b/twitter/twitter.php index d6d0ba7b..9c2804b1 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -682,7 +682,7 @@ function twitter_cron(App $a, $b) $abandon_days = 0; } - $abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400); + $abandon_limit = date(Temporal::MYSQL, time() - $abandon_days * 86400); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1'"); if (count($r)) { From e4f32f8ac8dbee577dc31195b1104add371f77eb Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 25 Jan 2018 23:28:13 -0500 Subject: [PATCH 3/6] Add Temporal::utcNow() --- public_server/public_server.php | 2 +- pumpio/pumpio.php | 4 ++-- statusnet/statusnet.php | 10 +++++----- testdrive/testdrive.php | 2 +- twitter/twitter.php | 14 +++++++------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/public_server/public_server.php b/public_server/public_server.php index 52c115a3..23777654 100644 --- a/public_server/public_server.php +++ b/public_server/public_server.php @@ -69,7 +69,7 @@ function public_server_cron($a,$b) { ]); q("update user set expire_notification_sent = '%s' where uid = %d", - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval($rr['uid']) ); } diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 7e34eab3..afdd3455 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -871,7 +871,7 @@ function pumpio_dounlike(&$a, $uid, $self, $post, $own_id) { } $r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `verb` = '%s' AND `uid` = %d AND `contact-id` = %d AND `thr-parent` = '%s'", - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), dbesc(ACTIVITY_LIKE), intval($uid), intval($contactid), @@ -1002,7 +1002,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) { `location`, `about`, `writable`, `blocked`, `readonly`, `pending` ) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0)", intval($uid), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), dbesc($contact->url), dbesc(normalise_link($contact->url)), dbesc(str_replace("acct:", "", $contact->id)), diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index c5b62a5d..ee0a6dab 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -936,7 +936,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) `location`, `about`, `writable`, `blocked`, `readonly`, `pending` ) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0 ) ", intval($uid), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), dbesc($contact->statusnet_profile_url), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(statusnet_address($contact)), @@ -977,7 +977,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval($contact_id) ); } else { @@ -1008,9 +1008,9 @@ function statusnet_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), dbesc($contact->statusnet_profile_url), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(statusnet_address($contact)), diff --git a/testdrive/testdrive.php b/testdrive/testdrive.php index efff8c28..4f434123 100644 --- a/testdrive/testdrive.php +++ b/testdrive/testdrive.php @@ -72,7 +72,7 @@ function testdrive_cron($a,$b) { ]); q("update user set expire_notification_sent = '%s' where uid = %d", - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval($rr['uid']) ); diff --git a/twitter/twitter.php b/twitter/twitter.php index 9c2804b1..cc12e8de 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -1017,7 +1017,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) `location`, `about`, `writable`, `blocked`, `readonly`, `pending`) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0)", intval($uid), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), dbesc("https://twitter.com/" . $contact->screen_name), dbesc(normalise_link("https://twitter.com/" . $contact->screen_name)), dbesc($contact->screen_name."@twitter.com"), @@ -1061,9 +1061,9 @@ function twitter_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), intval($contact_id) ); } @@ -1096,9 +1096,9 @@ function twitter_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), dbesc("https://twitter.com/".$contact->screen_name), dbesc(normalise_link("https://twitter.com/".$contact->screen_name)), dbesc($contact->screen_name."@twitter.com"), From cbc89d147d763cd57095ab22d6b068a68404c8ab Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 26 Jan 2018 07:30:06 -0500 Subject: [PATCH 4/6] Add Temporal::utc() shorthand to Temporal::convert() --- fromgplus/fromgplus.php | 4 ++-- public_server/public_server.php | 8 ++++---- pumpio/pumpio.php | 8 ++++---- statusnet/statusnet.php | 6 +++--- twitter/twitter.php | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index fa6c0e39..a65be286 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -520,12 +520,12 @@ function fromgplus_fetch($a, $uid) { if (function_exists("share_header")) $post .= share_header($item->object->actor->displayName, $item->object->actor->url, $item->object->actor->image->url, "", - Temporal::convert($item->object->published),$item->object->url); + Temporal::utc($item->object->published),$item->object->url); else $post .= "[share author='".str_replace("'", "'",$item->object->actor->displayName). "' profile='".$item->object->actor->url. "' avatar='".$item->object->actor->image->url. - "' posted='".Temporal::convert($item->object->published). + "' posted='".Temporal::utc($item->object->published). "' link='".$item->object->url."']"; $post .= fromgplus_html2bbcode($item->object->content); diff --git a/public_server/public_server.php b/public_server/public_server.php index 23777654..29cf0f60 100644 --- a/public_server/public_server.php +++ b/public_server/public_server.php @@ -39,7 +39,7 @@ function public_server_register_account($a,$b) { return; $r = q("UPDATE user set account_expires_on = '%s', expire = %d where uid = %d", - dbesc(Temporal::convert('now +' . $days . ' days')), + dbesc(Temporal::utc('now +' . $days . ' days')), intval($days_posts), intval($uid) ); @@ -87,7 +87,7 @@ function public_server_cron($a,$b) { if(count($r)) { foreach($r as $rr) q("update user set account_expires_on = '%s' where uid = %d", - dbesc(Temporal::convert('now +' . '6 days')), + dbesc(Temporal::utc('now +' . '6 days')), intval($rr['uid']) ); } @@ -100,7 +100,7 @@ function public_server_cron($a,$b) { if(count($r)) { foreach($r as $rr) q("update user set account_expires_on = '%s' where uid = %d", - dbesc(Temporal::convert('now +' . '6 days')), + dbesc(Temporal::utc('now +' . '6 days')), intval($rr['uid']) ); } @@ -138,7 +138,7 @@ function public_server_login($a,$b) { if(! $days) return; $r = q("UPDATE user set account_expires_on = '%s' where uid = %d and account_expires_on > '0000-00-00 00:00:00'", - dbesc(Temporal::convert('now +' . $days . ' days')), + dbesc(Temporal::utc('now +' . $days . ' days')), local_user() ); } diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index afdd3455..45dd5749 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -1211,11 +1211,11 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet if ($post->object->displayName != "") $postarray['title'] = $post->object->displayName; - $postarray['created'] = Temporal::convert($post->published); + $postarray['created'] = Temporal::utc($post->published); if (isset($post->updated)) - $postarray['edited'] = Temporal::convert($post->updated); + $postarray['edited'] = Temporal::utc($post->updated); elseif (isset($post->received)) - $postarray['edited'] = Temporal::convert($post->received); + $postarray['edited'] = Temporal::utc($post->received); else $postarray['edited'] = $postarray['created']; @@ -1230,7 +1230,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet $postarray['body'] = share_header($share_author, $post->object->author->url, $post->object->author->image->url, "", - Temporal::convert($post->object->created), + Temporal::utc($post->object->created), $post->links->self->href). $postarray['body']."[/share]"; diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index ee0a6dab..ae54e2fd 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -983,7 +983,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) } else { // update profile photos once every two weeks as we have no notification of when they change. //$update_photo = (($r[0]['avatar-date'] < Temporal::convert('now -2 days', '', '', )) ? true : false); - $update_photo = ($r[0]['avatar-date'] < Temporal::convert('now -12 hours')); + $update_photo = ($r[0]['avatar-date'] < Temporal::utc('now -12 hours')); // check that we have all the photos, this has been known to fail on occasion if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) { @@ -1197,8 +1197,8 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex $postarray['body'] = $converted["body"]; $postarray['tag'] = $converted["tags"]; - $postarray['created'] = Temporal::convert($content->created_at); - $postarray['edited'] = Temporal::convert($content->created_at); + $postarray['created'] = Temporal::utc($content->created_at); + $postarray['edited'] = Temporal::utc($content->created_at); if (is_string($content->place->name)) { $postarray["location"] = $content->place->name; diff --git a/twitter/twitter.php b/twitter/twitter.php index cc12e8de..0bffa4eb 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -1070,7 +1070,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) } else { // update profile photos once every two weeks as we have no notification of when they change. //$update_photo = (($r[0]['avatar-date'] < Temporal::convert('now -2 days', '', '', )) ? true : false); - $update_photo = ($r[0]['avatar-date'] < Temporal::convert('now -12 hours')); + $update_photo = ($r[0]['avatar-date'] < Temporal::utc('now -12 hours')); // check that we have all the photos, this has been known to fail on occasion if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) { @@ -1490,8 +1490,8 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis $converted = twitter_expand_entities($a, $postarray['body'], $post, false, $picture); $postarray['body'] = $converted["body"]; $postarray['tag'] = $converted["tags"]; - $postarray['created'] = Temporal::convert($post->created_at); - $postarray['edited'] = Temporal::convert($post->created_at); + $postarray['created'] = Temporal::utc($post->created_at); + $postarray['edited'] = Temporal::utc($post->created_at); $statustext = $converted["plain"]; From 13fb4a312dab2fefb8dd484b3492036391e80cb0 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 26 Jan 2018 19:33:46 -0500 Subject: [PATCH 5/6] Add Temporal::local() shorthand for Temporal::convert() --- .../dav_caldav_backend_virtual_friendica.inc.php | 8 ++++---- membersince/membersince.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php index 3baaa10c..092dbbd8 100644 --- a/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php +++ b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php @@ -68,8 +68,8 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual $component = dav_get_eventComponent($vevent); if ($row["adjust"]) { - $start = Temporal::convert($row["start"], date_default_timezone_get()); - $finish = Temporal::convert($row["finish"], date_default_timezone_get()); + $start = Temporal::local($row["start"]); + $finish = Temporal::local($row["finish"]); } else { $start = $row["start"]; $finish = $row["finish"]; @@ -116,8 +116,8 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual private function jqcal2wdcal($row, $calendar, $base_path) { if ($row["adjust"]) { - $start = Temporal::convert($row["start"], date_default_timezone_get()); - $finish = Temporal::convert($row["finish"], date_default_timezone_get()); + $start = Temporal::local($row["start"]); + $finish = Temporal::local($row["finish"]); } else { $start = $row["start"]; $finish = $row["finish"]; diff --git a/membersince/membersince.php b/membersince/membersince.php index b8bbca49..fb923bde 100644 --- a/membersince/membersince.php +++ b/membersince/membersince.php @@ -26,8 +26,8 @@ function membersince_uninstall() function membersince_display(&$a, &$b) { // Works in Vier - $b = preg_replace('/<\/dl>/', "\n\n\n
\n
" . L10n::t('Member since:') . "
\n
" . Temporal::convert($a->profile['register_date'], date_default_timezone_get()) . "
\n
", $b, 1); + $b = preg_replace('/<\/dl>/', "\n\n\n
\n
" . L10n::t('Member since:') . "
\n
" . Temporal::local($a->profile['register_date']) . "
\n
", $b, 1); // Trying for Frio - //$b = preg_replace('/<\/div>/', "

" . L10n::t('Member since:') . "
" . Temporal::convert($a->profile['register_date'], date_default_timezone_get()) . "
", $b, 1); + //$b = preg_replace('/<\/div>/', "

" . L10n::t('Member since:') . "
" . Temporal::local($a->profile['register_date']) . "
", $b, 1); } From 1900da6c421a939b9a98994e974f2ab01d6ded74 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 26 Jan 2018 21:39:02 -0500 Subject: [PATCH 6/6] Move Temporal::convert() to DateTimeFormat::convert() --- dav/common/calendar.fnk.php | 6 ++--- dav/common/calendar_rendering.fnk.php | 8 +++--- dav/common/wdcal_backend.inc.php | 10 +++---- dav/common/wdcal_edit.inc.php | 10 +++---- ...v_caldav_backend_virtual_friendica.inc.php | 18 ++++++------- dwpost/dwpost.php | 2 +- fromgplus/fromgplus.php | 6 ++--- ijpost/ijpost.php | 2 +- ljpost/ljpost.php | 2 +- membersince/membersince.php | 6 ++--- public_server/public_server.php | 12 ++++----- pumpio/pumpio.php | 18 ++++++------- statusnet/statusnet.php | 22 ++++++++-------- testdrive/testdrive.php | 6 ++--- twitter/twitter.php | 26 +++++++++---------- 15 files changed, 77 insertions(+), 77 deletions(-) diff --git a/dav/common/calendar.fnk.php b/dav/common/calendar.fnk.php index 1245ee2e..ef1a9b0c 100644 --- a/dav/common/calendar.fnk.php +++ b/dav/common/calendar.fnk.php @@ -1,6 +1,6 @@ format("U"); } diff --git a/dav/common/calendar_rendering.fnk.php b/dav/common/calendar_rendering.fnk.php index ae6e39dd..bc13ce39 100644 --- a/dav/common/calendar_rendering.fnk.php +++ b/dav/common/calendar_rendering.fnk.php @@ -1,6 +1,6 @@ getTimestamp() < time() ? 1 : 0); q("INSERT INTO %s%snotifications (`calendar_id`, `calendarobject_id`, `alert_date`, `notified`) VALUES (%d, %d, CONVERT_TZ('%s', '$timezoneOffset', @@session.time_zone), %d)", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($calendar["id"]), IntVal($calendarobject["id"]), $alarm->format(Temporal::MYSQL), $notified + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($calendar["id"]), IntVal($calendarobject["id"]), $alarm->format(DateTimeFormat::MYSQL), $notified ); } diff --git a/dav/common/wdcal_backend.inc.php b/dav/common/wdcal_backend.inc.php index 5418c90a..d66251f4 100644 --- a/dav/common/wdcal_backend.inc.php +++ b/dav/common/wdcal_backend.inc.php @@ -1,7 +1,7 @@ setDateTime(new DateTime(date(Temporal::MYSQL, IntVal($_REQUEST["CalendarStartTime"]))), $type); + $datetime_start->setDateTime(new DateTime(date(DateTimeFormat::MYSQL, IntVal($_REQUEST["CalendarStartTime"]))), $type); $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); - $datetime_end->setDateTime(new DateTime(date(Temporal::MYSQL, IntVal($_REQUEST["CalendarEndTime"]))), $type); + $datetime_end->setDateTime(new DateTime(date(DateTimeFormat::MYSQL, IntVal($_REQUEST["CalendarEndTime"]))), $type); $component->add($datetime_start); $component->add($datetime_end); @@ -183,9 +183,9 @@ function wdcal_print_feed($base_path = "") else $type = Sabre\VObject\Property\DateTime::LOCALTZ; $datetime_start = new Sabre\VObject\Property\DateTime("DTSTART"); - $datetime_start->setDateTime(new DateTime(date(Temporal::MYSQL, IntVal($_REQUEST["CalendarStartTime"]))), $type); + $datetime_start->setDateTime(new DateTime(date(DateTimeFormat::MYSQL, IntVal($_REQUEST["CalendarStartTime"]))), $type); $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); - $datetime_end->setDateTime(new DateTime(date(Temporal::MYSQL, IntVal($_REQUEST["CalendarEndTime"]))), $type); + $datetime_end->setDateTime(new DateTime(date(DateTimeFormat::MYSQL, IntVal($_REQUEST["CalendarEndTime"]))), $type); $component->__unset("DTSTART"); $component->__unset("DTEND"); diff --git a/dav/common/wdcal_edit.inc.php b/dav/common/wdcal_edit.inc.php index 8154a68b..49cc1523 100644 --- a/dav/common/wdcal_edit.inc.php +++ b/dav/common/wdcal_edit.inc.php @@ -1,7 +1,7 @@ setDateTime(new DateTime(date(Temporal::MYSQL, $ts_start)), $type); + $datetime_start->setDateTime(new DateTime(date(DateTimeFormat::MYSQL, $ts_start)), $type); $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); - $datetime_end->setDateTime(new DateTime(date(Temporal::MYSQL, $ts_end)), $type); + $datetime_end->setDateTime(new DateTime(date(DateTimeFormat::MYSQL, $ts_end)), $type); $component->__unset("DTSTART"); $component->__unset("DTEND"); @@ -599,7 +599,7 @@ function wdcal_set_component_recurrence(&$component, &$localization) $date = $localization->date_local2timestamp($_REQUEST["rec_until_date"]); $part_until = ";UNTIL=" . date("Ymd", $date); $datetime_until = new Sabre\VObject\Property\DateTime("UNTIL"); - $datetime_until->setDateTime(new DateTime(date(Temporal::MYSQL, $date)), Sabre\VObject\Property\DateTime::DATE); + $datetime_until->setDateTime(new DateTime(date(DateTimeFormat::MYSQL, $date)), Sabre\VObject\Property\DateTime::DATE); break; case "count": $part_until = ";COUNT=" . IntVal($_REQUEST["rec_until_count"]); @@ -646,7 +646,7 @@ function wdcal_set_component_recurrence(&$component, &$localization) if (isset($_REQUEST["rec_exceptions"])) { $arr = array(); foreach ($_REQUEST["rec_exceptions"] as $except) { - $arr[] = new DateTime(date(Temporal::MYSQL, $except)); + $arr[] = new DateTime(date(DateTimeFormat::MYSQL, $except)); } /** @var Sabre\VObject\Property\MultiDateTime $prop */ $prop = Sabre\VObject\Property::create("EXDATE"); diff --git a/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php index 092dbbd8..b02b9150 100644 --- a/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php +++ b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php @@ -1,7 +1,7 @@ setDateTime(new DateTime(date(Temporal::MYSQL, $ts_start)), $type); + $datetime_start->setDateTime(new DateTime(date(DateTimeFormat::MYSQL, $ts_start)), $type); $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); - $datetime_end->setDateTime(new DateTime(date(Temporal::MYSQL, $ts_end)), $type); + $datetime_end->setDateTime(new DateTime(date(DateTimeFormat::MYSQL, $ts_end)), $type); $component->add($datetime_start); $component->add($datetime_end); @@ -116,8 +116,8 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual private function jqcal2wdcal($row, $calendar, $base_path) { if ($row["adjust"]) { - $start = Temporal::local($row["start"]); - $finish = Temporal::local($row["finish"]); + $start = DateTimeFormat::local($row["start"]); + $finish = DateTimeFormat::local($row["finish"]); } else { $start = $row["start"]; $finish = $row["finish"]; @@ -175,11 +175,11 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual } if ($date_from != "") { - if (is_numeric($date_from)) $sql_where .= " AND `finish` >= '" . date(Temporal::MYSQL, $date_from) . "'"; + if (is_numeric($date_from)) $sql_where .= " AND `finish` >= '" . date(DateTimeFormat::MYSQL, $date_from) . "'"; else $sql_where .= " AND `finish` >= '" . dbesc($date_from) . "'"; } if ($date_to != "") { - if (is_numeric($date_to)) $sql_where .= " AND `start` <= '" . date(Temporal::MYSQL, $date_to) . "'"; + if (is_numeric($date_to)) $sql_where .= " AND `start` <= '" . date(DateTimeFormat::MYSQL, $date_to) . "'"; else $sql_where .= " AND `start` <= '" . dbesc($date_to) . "'"; } $ret = []; diff --git a/dwpost/dwpost.php b/dwpost/dwpost.php index 3730aa2b..fe4a53ef 100644 --- a/dwpost/dwpost.php +++ b/dwpost/dwpost.php @@ -187,7 +187,7 @@ function dwpost_send(&$a,&$b) { $post = xmlify($post); $tags = dwpost_get_tags($b['tag']); - $date = Temporal::convert($b['created'], $tz); + $date = DateTimeFormat::convert($b['created'], $tz); $year = intval(substr($date,0,4)); $mon = intval(substr($date,5,2)); $day = intval(substr($date,8,2)); diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index a65be286..b8d9511a 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -14,8 +14,8 @@ use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Object\Image; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; -use Friendica\Util\Temporal; require_once 'mod/share.php'; require_once 'mod/parse_url.php'; @@ -520,12 +520,12 @@ function fromgplus_fetch($a, $uid) { if (function_exists("share_header")) $post .= share_header($item->object->actor->displayName, $item->object->actor->url, $item->object->actor->image->url, "", - Temporal::utc($item->object->published),$item->object->url); + DateTimeFormat::utc($item->object->published),$item->object->url); else $post .= "[share author='".str_replace("'", "'",$item->object->actor->displayName). "' profile='".$item->object->actor->url. "' avatar='".$item->object->actor->image->url. - "' posted='".Temporal::utc($item->object->published). + "' posted='".DateTimeFormat::utc($item->object->published). "' link='".$item->object->url."']"; $post .= fromgplus_html2bbcode($item->object->content); diff --git a/ijpost/ijpost.php b/ijpost/ijpost.php index 3c4e917d..ffafa5ee 100644 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@ -186,7 +186,7 @@ function ijpost_send(&$a,&$b) { $post = xmlify($post); $tags = ijpost_get_tags($b['tag']); - $date = Temporal::convert($b['created'], $tz); + $date = DateTimeFormat::convert($b['created'], $tz); $year = intval(substr($date,0,4)); $mon = intval(substr($date,5,2)); $day = intval(substr($date,8,2)); diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index ff89e5e6..2a14172f 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -187,7 +187,7 @@ function ljpost_send(&$a,&$b) { $post = xmlify($post); $tags = ljpost_get_tags($b['tag']); - $date = Temporal::convert($b['created'], $tz); + $date = DateTimeFormat::convert($b['created'], $tz); $year = intval(substr($date,0,4)); $mon = intval(substr($date,5,2)); $day = intval(substr($date,8,2)); diff --git a/membersince/membersince.php b/membersince/membersince.php index fb923bde..c1d38b83 100644 --- a/membersince/membersince.php +++ b/membersince/membersince.php @@ -9,7 +9,7 @@ use Friendica\Core\Addon; use Friendica\Core\L10n; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require_once 'include/datetime.php'; @@ -26,8 +26,8 @@ function membersince_uninstall() function membersince_display(&$a, &$b) { // Works in Vier - $b = preg_replace('/<\/dl>/', "\n\n\n
\n
" . L10n::t('Member since:') . "
\n
" . Temporal::local($a->profile['register_date']) . "
\n
", $b, 1); + $b = preg_replace('/<\/dl>/', "\n\n\n
\n
" . L10n::t('Member since:') . "
\n
" . DateTimeFormat::local($a->profile['register_date']) . "
\n
", $b, 1); // Trying for Frio - //$b = preg_replace('/<\/div>/', "

" . L10n::t('Member since:') . "
" . Temporal::local($a->profile['register_date']) . "
", $b, 1); + //$b = preg_replace('/<\/div>/', "

" . L10n::t('Member since:') . "
" . DateTimeFormat::local($a->profile['register_date']) . "
", $b, 1); } diff --git a/public_server/public_server.php b/public_server/public_server.php index 29cf0f60..a5c4cec7 100644 --- a/public_server/public_server.php +++ b/public_server/public_server.php @@ -10,7 +10,7 @@ use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Model\User; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; function public_server_install() { @@ -39,7 +39,7 @@ function public_server_register_account($a,$b) { return; $r = q("UPDATE user set account_expires_on = '%s', expire = %d where uid = %d", - dbesc(Temporal::utc('now +' . $days . ' days')), + dbesc(DateTimeFormat::utc('now +' . $days . ' days')), intval($days_posts), intval($uid) ); @@ -69,7 +69,7 @@ function public_server_cron($a,$b) { ]); q("update user set expire_notification_sent = '%s' where uid = %d", - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval($rr['uid']) ); } @@ -87,7 +87,7 @@ function public_server_cron($a,$b) { if(count($r)) { foreach($r as $rr) q("update user set account_expires_on = '%s' where uid = %d", - dbesc(Temporal::utc('now +' . '6 days')), + dbesc(DateTimeFormat::utc('now +' . '6 days')), intval($rr['uid']) ); } @@ -100,7 +100,7 @@ function public_server_cron($a,$b) { if(count($r)) { foreach($r as $rr) q("update user set account_expires_on = '%s' where uid = %d", - dbesc(Temporal::utc('now +' . '6 days')), + dbesc(DateTimeFormat::utc('now +' . '6 days')), intval($rr['uid']) ); } @@ -138,7 +138,7 @@ function public_server_login($a,$b) { if(! $days) return; $r = q("UPDATE user set account_expires_on = '%s' where uid = %d and account_expires_on > '0000-00-00 00:00:00'", - dbesc(Temporal::utc('now +' . $days . ' days')), + dbesc(DateTimeFormat::utc('now +' . $days . ' days')), local_user() ); } diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 45dd5749..1e416f47 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -18,7 +18,7 @@ use Friendica\Model\Item; use Friendica\Model\Queue; use Friendica\Util\Network; use Friendica\Model\User; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require 'addon/pumpio/oauth/http.php'; require 'addon/pumpio/oauth/oauth_client.php'; @@ -672,7 +672,7 @@ function pumpio_sync(&$a) { if ($abandon_days < 1) $abandon_days = 0; - $abandon_limit = date(Temporal::MYSQL, time() - $abandon_days * 86400); + $abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'import' AND `v` = '1' ORDER BY RAND() "); if(count($r)) { @@ -871,7 +871,7 @@ function pumpio_dounlike(&$a, $uid, $self, $post, $own_id) { } $r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `verb` = '%s' AND `uid` = %d AND `contact-id` = %d AND `thr-parent` = '%s'", - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), dbesc(ACTIVITY_LIKE), intval($uid), intval($contactid), @@ -1002,7 +1002,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) { `location`, `about`, `writable`, `blocked`, `readonly`, `pending` ) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0)", intval($uid), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), dbesc($contact->url), dbesc(normalise_link($contact->url)), dbesc(str_replace("acct:", "", $contact->id)), @@ -1211,11 +1211,11 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet if ($post->object->displayName != "") $postarray['title'] = $post->object->displayName; - $postarray['created'] = Temporal::utc($post->published); + $postarray['created'] = DateTimeFormat::utc($post->published); if (isset($post->updated)) - $postarray['edited'] = Temporal::utc($post->updated); + $postarray['edited'] = DateTimeFormat::utc($post->updated); elseif (isset($post->received)) - $postarray['edited'] = Temporal::utc($post->received); + $postarray['edited'] = DateTimeFormat::utc($post->received); else $postarray['edited'] = $postarray['created']; @@ -1230,7 +1230,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet $postarray['body'] = share_header($share_author, $post->object->author->url, $post->object->author->image->url, "", - Temporal::utc($post->object->created), + DateTimeFormat::utc($post->object->created), $post->links->self->href). $postarray['body']."[/share]"; @@ -1238,7 +1238,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet $postarray['body'] = "[share author='".$share_author. "' profile='".$post->object->author->url. "' avatar='".$post->object->author->image->url. - "' posted='".Temporal::convert($post->object->created, 'UTC', 'UTC', ). + "' posted='".DateTimeFormat::convert($post->object->created, 'UTC', 'UTC', ). "' link='".$post->links->self->href."']".$postarray['body']."[/share]"; */ } else { diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index ae54e2fd..22e8f5f9 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -53,8 +53,8 @@ use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\Photo; use Friendica\Model\User; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; -use Friendica\Util\Temporal; function statusnet_install() { @@ -760,7 +760,7 @@ function statusnet_cron(App $a, $b) $abandon_days = 0; } - $abandon_limit = date(Temporal::MYSQL, time() - $abandon_days * 86400); + $abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()"); if (count($r)) { @@ -936,7 +936,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) `location`, `about`, `writable`, `blocked`, `readonly`, `pending` ) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0 ) ", intval($uid), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), dbesc($contact->statusnet_profile_url), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(statusnet_address($contact)), @@ -977,13 +977,13 @@ function statusnet_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval($contact_id) ); } else { // update profile photos once every two weeks as we have no notification of when they change. - //$update_photo = (($r[0]['avatar-date'] < Temporal::convert('now -2 days', '', '', )) ? true : false); - $update_photo = ($r[0]['avatar-date'] < Temporal::utc('now -12 hours')); + //$update_photo = (($r[0]['avatar-date'] < DateTimeFormat::convert('now -2 days', '', '', )) ? true : false); + $update_photo = ($r[0]['avatar-date'] < DateTimeFormat::utc('now -12 hours')); // check that we have all the photos, this has been known to fail on occasion if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) { @@ -1008,9 +1008,9 @@ function statusnet_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(Temporal::utcNow()), - dbesc(Temporal::utcNow()), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), dbesc($contact->statusnet_profile_url), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(statusnet_address($contact)), @@ -1197,8 +1197,8 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex $postarray['body'] = $converted["body"]; $postarray['tag'] = $converted["tags"]; - $postarray['created'] = Temporal::utc($content->created_at); - $postarray['edited'] = Temporal::utc($content->created_at); + $postarray['created'] = DateTimeFormat::utc($content->created_at); + $postarray['edited'] = DateTimeFormat::utc($content->created_at); if (is_string($content->place->name)) { $postarray["location"] = $content->place->name; diff --git a/testdrive/testdrive.php b/testdrive/testdrive.php index 4f434123..5c3930cd 100644 --- a/testdrive/testdrive.php +++ b/testdrive/testdrive.php @@ -10,7 +10,7 @@ use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Model\User; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; function testdrive_install() { @@ -44,7 +44,7 @@ function testdrive_register_account($a,$b) { return; $r = q("UPDATE user set account_expires_on = '%s' where uid = %d", - dbesc(Temporal::convert('now +' . $days . ' days')), + dbesc(DateTimeFormat::convert('now +' . $days . ' days')), intval($uid) ); @@ -72,7 +72,7 @@ function testdrive_cron($a,$b) { ]); q("update user set expire_notification_sent = '%s' where uid = %d", - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval($rr['uid']) ); diff --git a/twitter/twitter.php b/twitter/twitter.php index 0bffa4eb..bf85f081 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -77,8 +77,8 @@ use Friendica\Model\Photo; use Friendica\Model\Queue; use Friendica\Model\User; use Friendica\Object\Image; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; -use Friendica\Util\Temporal; require_once 'boot.php'; require_once 'include/dba.php'; @@ -682,7 +682,7 @@ function twitter_cron(App $a, $b) $abandon_days = 0; } - $abandon_limit = date(Temporal::MYSQL, time() - $abandon_days * 86400); + $abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1'"); if (count($r)) { @@ -1017,7 +1017,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) `location`, `about`, `writable`, `blocked`, `readonly`, `pending`) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0)", intval($uid), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), dbesc("https://twitter.com/" . $contact->screen_name), dbesc(normalise_link("https://twitter.com/" . $contact->screen_name)), dbesc($contact->screen_name."@twitter.com"), @@ -1061,16 +1061,16 @@ function twitter_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(Temporal::utcNow()), - dbesc(Temporal::utcNow()), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval($contact_id) ); } } else { // update profile photos once every two weeks as we have no notification of when they change. - //$update_photo = (($r[0]['avatar-date'] < Temporal::convert('now -2 days', '', '', )) ? true : false); - $update_photo = ($r[0]['avatar-date'] < Temporal::utc('now -12 hours')); + //$update_photo = (($r[0]['avatar-date'] < DateTimeFormat::convert('now -2 days', '', '', )) ? true : false); + $update_photo = ($r[0]['avatar-date'] < DateTimeFormat::utc('now -12 hours')); // check that we have all the photos, this has been known to fail on occasion if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) { @@ -1096,9 +1096,9 @@ function twitter_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(Temporal::utcNow()), - dbesc(Temporal::utcNow()), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), dbesc("https://twitter.com/".$contact->screen_name), dbesc(normalise_link("https://twitter.com/".$contact->screen_name)), dbesc($contact->screen_name."@twitter.com"), @@ -1490,8 +1490,8 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis $converted = twitter_expand_entities($a, $postarray['body'], $post, false, $picture); $postarray['body'] = $converted["body"]; $postarray['tag'] = $converted["tags"]; - $postarray['created'] = Temporal::utc($post->created_at); - $postarray['edited'] = Temporal::utc($post->created_at); + $postarray['created'] = DateTimeFormat::utc($post->created_at); + $postarray['edited'] = DateTimeFormat::utc($post->created_at); $statustext = $converted["plain"];