]> git.mxchange.org Git - friendica-addons.git/commitdiff
Add Temporal::MYSQL constant
authorHypolite Petovan <mrpetovan@gmail.com>
Fri, 26 Jan 2018 03:00:29 +0000 (22:00 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Sat, 3 Feb 2018 16:40:38 +0000 (11:40 -0500)
dav/common/calendar.fnk.php
dav/common/calendar_rendering.fnk.php
dav/common/wdcal_backend.inc.php
dav/common/wdcal_edit.inc.php
dav/friendica/dav_caldav_backend_virtual_friendica.inc.php
pumpio/pumpio.php
statusnet/statusnet.php
twitter/twitter.php

index 11f31f7de4e7f3792dec1def9348e12678a89319..1245ee2e8d86354fb2aa0993dd510d9375a08710 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\Util\Temporal;
 
 define("DAV_ACL_READ", "{DAV:}read");
 define("DAV_ACL_WRITE", "{DAV:}write");
@@ -150,7 +151,7 @@ function vcard_source_compile($vcardsource)
  */
 function wdcal_php2MySqlTime($phpDate)
 {
-       return date("Y-m-d H:i:s", $phpDate);
+       return date(Temporal::MYSQL, $phpDate);
 }
 
 /**
@@ -159,7 +160,7 @@ function wdcal_php2MySqlTime($phpDate)
  */
 function wdcal_mySql2PhpTime($sqlDate)
 {
-       $ts = DateTime::createFromFormat("Y-m-d H:i:s", $sqlDate);
+       $ts = DateTime::createFromFormat(Temporal::MYSQL, $sqlDate);
        return $ts->format("U");
 }
 
index d80892f7ccac8d630a3c506945c2e3cddbe960f6..ae6e39dd0d316b4fc9df2f6439ab6c454d8aa187 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\Util\Temporal;
 
 
 /**
@@ -109,15 +110,15 @@ function renderCalDavEntry_data(&$calendar, &$calendarobject)
 
                q("INSERT INTO %s%sjqcalendar (`calendar_id`, `calendarobject_id`, `Summary`, `StartTime`, `EndTime`, `IsEditable`, `IsAllDayEvent`, `IsRecurring`, `Color`) VALUES
                        (%d, %d, '%s', CONVERT_TZ('%s', '$timezoneOffset', @@session.time_zone), CONVERT_TZ('%s', '$timezoneOffset', @@session.time_zone), %d, %d, %d, '%s')",
-                       CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($calendar["id"]), IntVal($calendarobject["id"]), dbesc($event["summary"]), date("Y-m-d H:i:s", $start),
-                       date("Y-m-d H:i:s", $last_end), 1, $allday, $recurring, dbesc(substr($event["color"], 1))
+                       CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($calendar["id"]), IntVal($calendarobject["id"]), dbesc($event["summary"]), date(Temporal::MYSQL, $start),
+                       date(Temporal::MYSQL, $last_end), 1, $allday, $recurring, dbesc(substr($event["color"], 1))
                );
 
                foreach ($alarms as $alarm) {
                        $alarm    = renderCalDavEntry_calcalarm($alarm, $component);
                        $notified = ($alarm->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
                        );
                }
 
index a3e18eb394eedfe8ab9110f4efff91410430d646..5418c90a367585ff93296c5a0f54f988d3870c70 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 use Friendica\Core\L10n;
+use Friendica\Util\Temporal;
 
 /**
  * @param mixed $obj
@@ -100,9 +101,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->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");
index f4ac90c9746b71cb536a6704646d27e46775fd0b..8154a68b59087fce72192c777a151e10d09f1ea5 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 use Friendica\Core\L10n;
+use Friendica\Util\Temporal;
 
 /**
  * @param wdcal_local $localization
@@ -520,9 +521,9 @@ function wdcal_set_component_date(&$component, &$localization)
                $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", $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");
index 405bbb19bb8f4ed708b2fc43507f977cc3743014..3baaa10c8272c3bab590271d6f09bdf24e7d4357 100644 (file)
@@ -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 = [];
index bdc56795d74058209e7428a4561afe270f2871e6..7e34eab3269ca85ae47ba759eb5c425a81db1739 100644 (file)
@@ -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)) {
index 5709541276a28a0f838b72c4b16c1f0758ed9cdf..c5b62a5d43df3fed440f05441854210427d5e6a6 100644 (file)
@@ -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)) {
index d6d0ba7bccb0c794049d7646bbc37a3f50a53178..9c2804b1a34a47408ed03bf5992e427eb37f90ae 100644 (file)
@@ -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)) {