]> git.mxchange.org Git - friendica.git/commitdiff
Move ATOM_TIME to Temporal::ATOM
authorHypolite Petovan <mrpetovan@gmail.com>
Fri, 26 Jan 2018 02:33:43 +0000 (21:33 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Sat, 3 Feb 2018 13:56:52 +0000 (08:56 -0500)
boot.php
include/api.php
include/event.php
include/text.php
src/Protocol/DFRN.php
src/Protocol/Diaspora.php
src/Protocol/OStatus.php
src/Util/Temporal.php
src/Worker/OnePoll.php

index 27a5e8b3e4cbc1176b417561544d729fd959947f..18c76587c04bc51c1d307b92c5ac6e69432834a2 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -56,7 +56,6 @@ const DB_UPDATE_FAILED = 2;      // Database check failed
  * This can be used in HTML and JavaScript where needed a line break.
  */
 define('EOL',                    "<br />\r\n");
-define('ATOM_TIME',              'Y-m-d\TH:i:s\Z');
 
 /**
  * @brief Image storage quality.
@@ -1150,7 +1149,7 @@ function feed_birthday($uid, $tz)
                        if ($t_dob < $now) {
                                $bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
                        }
-                       $birthday = Temporal::convert($bd, 'UTC', $tz, ATOM_TIME);
+                       $birthday = Temporal::convert($bd, 'UTC', $tz, Temporal::ATOM);
                }
        }
 
index 727b2f028dc5541f1a6fb99f2e228e635105c0ea..d24e4e297e4985c28055bb78a679926267dd744e 100644 (file)
@@ -460,7 +460,7 @@ function api_rss_extra(App $a, $arr, $user_info)
                'self'         => System::baseUrl() . "/" . $a->query_string,
                'base'         => System::baseUrl(),
                'updated'      => api_date(null),
-               'atom_updated' => Temporal::convert('now', 'UTC', 'UTC', ATOM_TIME),
+               'atom_updated' => Temporal::convert('now', 'UTC', 'UTC', Temporal::ATOM),
                'language'     => $user_info['language'],
                'logo'         => System::baseUrl() . "/images/friendica-32.png",
        ];
@@ -3207,7 +3207,7 @@ function api_account_rate_limit_status($type)
                                '@attributes' => ["type" => "integer"],
                                'hourly-limit' => '150',
                                '@attributes2' => ["type" => "integer"],
-                               'reset-time' => Temporal::convert('now + 1 hour', 'UTC', 'UTC', ATOM_TIME),
+                               'reset-time' => Temporal::convert('now + 1 hour', 'UTC', 'UTC', Temporal::ATOM),
                                '@attributes3' => ["type" => "datetime"],
                                'reset_time_in_seconds' => strtotime('now + 1 hour'),
                                '@attributes4' => ["type" => "integer"],
@@ -3217,7 +3217,7 @@ function api_account_rate_limit_status($type)
                                'reset_time_in_seconds' => strtotime('now + 1 hour'),
                                'remaining_hits' => '150',
                                'hourly_limit' => '150',
-                               'reset_time' => api_date(Temporal::convert('now + 1 hour', 'UTC', 'UTC', ATOM_TIME)),
+                               'reset_time' => api_date(Temporal::convert('now + 1 hour', 'UTC', 'UTC', Temporal::ATOM)),
                        ];
        }
 
index 67093627971cc5546350d4ccb60d9a56758720ab..59ac8d4a2ca02ba08c5c54a6b18e42be613f433d 100644 (file)
@@ -57,13 +57,13 @@ function format_event_html($ev, $simple = false) {
        $o .= '<div class="summary event-summary">' . bbcode($ev['summary']) . '</div>' . "\r\n";
 
        $o .= '<div class="event-start"><span class="event-label">' . L10n::t('Starts:') . '</span>&nbsp;<span class="dtstart" title="'
-               . Temporal::convert($ev['start'], 'UTC', 'UTC', (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
+               . Temporal::convert($ev['start'], 'UTC', 'UTC', (($ev['adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s' ))
                . '" >'.$event_start
                . '</span></div>' . "\r\n";
 
        if (! $ev['nofinish']) {
                $o .= '<div class="event-end" ><span class="event-label">' . L10n::t('Finishes:') . '</span>&nbsp;<span class="dtend" title="'
-                       . Temporal::convert($ev['finish'], 'UTC', 'UTC', (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
+                       . Temporal::convert($ev['finish'], 'UTC', 'UTC', (($ev['adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s' ))
                        . '" >'.$event_end
                        . '</span></div>' . "\r\n";
        }
@@ -925,7 +925,7 @@ function format_event_item($item) {
 
        // Convert the time to different formats.
        $dtstart_dt = (($item['event-adjust']) ? day_translate(Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat)) : day_translate(Temporal::convert($item['event-start'], 'UTC', 'UTC', $dformat)));
-       $dtstart_title = Temporal::convert($item['event-start'], 'UTC', 'UTC', (($item['event-adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s'));
+       $dtstart_title = Temporal::convert($item['event-start'], 'UTC', 'UTC', (($item['event-adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s'));
        // Format: Jan till Dec.
        $month_short = (($item['event-adjust']) ? day_short_translate(Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'M')) : day_short_translate(Temporal::convert($item['event-start'], 'UTC', 'UTC', 'M')));
        // Format: 1 till 31.
@@ -937,7 +937,7 @@ function format_event_item($item) {
        if (!$item['event-nofinish']) {
                $finish = true;
                $dtend_dt  = (($item['event-adjust']) ? day_translate(Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat)) : day_translate(Temporal::convert($item['event-finish'], 'UTC', 'UTC', $dformat)));
-               $dtend_title = Temporal::convert($item['event-finish'], 'UTC', 'UTC', (($item['event-adjust'])   ? ATOM_TIME : 'Y-m-d\TH:i:s'));
+               $dtend_title = Temporal::convert($item['event-finish'], 'UTC', 'UTC', (($item['event-adjust'])   ? Temporal::ATOM : 'Y-m-d\TH:i:s'));
                $end_short = (($item['event-adjust']) ? day_short_translate(Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat_short)) : day_short_translate(Temporal::convert($item['event-finish'], 'UTC', 'UTC', $dformat_short)));
                $end_time = (($item['event-adjust']) ? Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $tformat) : Temporal::convert($item['event-finish'], 'UTC', 'UTC', $tformat));
                // Check if start and finish time is at the same day.
index 72787ae57e3902ae14675fb492783ed9fd92d78e..def479ce337ffb50a3e929c663cd1eaf7bb6cc6d 100644 (file)
@@ -723,7 +723,7 @@ function logger($msg, $level = 0) {
 
        $callers = debug_backtrace();
        $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n",
-                       Temporal::convert('now', 'UTC', 'UTC', 'Y-m-d\TH:i:s\Z'),
+                       Temporal::convert('now', 'UTC', 'UTC', Temporal::ATOM),
                        $process_id,
                        $LOGGER_LEVELS[$level],
                        basename($callers[0]['file']),
index 871358d988bcc572a9d87740843e3a93103e6cae..3145e21f2b933d14205b3aa0dad25eeef920c914 100644 (file)
@@ -421,7 +421,7 @@ class DFRN
 
                XML::addElement($doc, $mail, "dfrn:id", $item['uri']);
                XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']);
-               XML::addElement($doc, $mail, "dfrn:sentdate", Temporal::convert($item['created'] . '+00:00', 'UTC', 'UTC', ATOM_TIME));
+               XML::addElement($doc, $mail, "dfrn:sentdate", Temporal::convert($item['created'] . '+00:00', 'UTC', 'UTC', Temporal::ATOM));
                XML::addElement($doc, $mail, "dfrn:subject", $item['title']);
                XML::addElement($doc, $mail, "dfrn:content", $item['body']);
 
@@ -587,7 +587,7 @@ class DFRN
 
                /// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP"
 
-               XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", ATOM_TIME));
+               XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", Temporal::ATOM));
 
                $author = self::addAuthor($doc, $owner, $authorelement, $public);
                $root->appendChild($author);
@@ -622,9 +622,9 @@ class DFRN
 
                $author = $doc->createElement($authorelement);
 
-               $namdate = Temporal::convert($owner['name-date'].'+00:00', 'UTC', 'UTC', ATOM_TIME);
-               $uridate = Temporal::convert($owner['uri-date'].'+00:00', 'UTC', 'UTC', ATOM_TIME);
-               $picdate = Temporal::convert($owner['avatar-date'].'+00:00', 'UTC', 'UTC', ATOM_TIME);
+               $namdate = Temporal::convert($owner['name-date'].'+00:00', 'UTC', 'UTC', Temporal::ATOM);
+               $uridate = Temporal::convert($owner['uri-date'].'+00:00', 'UTC', 'UTC', Temporal::ATOM);
+               $picdate = Temporal::convert($owner['avatar-date'].'+00:00', 'UTC', 'UTC', Temporal::ATOM);
 
                $attributes = [];
 
@@ -903,7 +903,7 @@ class DFRN
                }
 
                if ($item['deleted']) {
-                       $attributes = ["ref" => $item['uri'], "when" => Temporal::convert($item['edited'] . '+00:00', 'UTC', 'UTC', ATOM_TIME)];
+                       $attributes = ["ref" => $item['uri'], "when" => Temporal::convert($item['edited'] . '+00:00', 'UTC', 'UTC', Temporal::ATOM)];
                        return XML::createElement($doc, "at:deleted-entry", "", $attributes);
                }
 
@@ -983,8 +983,8 @@ class DFRN
                XML::addElement($doc, $entry, "id", $item["uri"]);
                XML::addElement($doc, $entry, "title", $item["title"]);
 
-               XML::addElement($doc, $entry, "published", Temporal::convert($item["created"] . "+00:00", "UTC", "UTC", ATOM_TIME));
-               XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"] . "+00:00", "UTC", "UTC", ATOM_TIME));
+               XML::addElement($doc, $entry, "published", Temporal::convert($item["created"] . "+00:00", "UTC", "UTC", Temporal::ATOM));
+               XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"] . "+00:00", "UTC", "UTC", Temporal::ATOM));
 
                // "dfrn:env" is used to read the content
                XML::addElement($doc, $entry, "dfrn:env", base64url_encode($body, true));
index 3350cfc0ffb19b114de72142fa8d317975857d8a..db18fbb47866b9d2bbc6679484312598a1625b5f 100644 (file)
@@ -3593,7 +3593,7 @@ class Diaspora
                        $eventdata['guid'] = $event['guid'];
                }
 
-               $mask = 'Y-m-d\TH:i:s\Z';
+               $mask = Temporal::ATOM;
 
                /// @todo - establish "all day" events in Friendica
                $eventdata["all_day"] = "false";
@@ -3652,7 +3652,7 @@ class Diaspora
 
                $public = (($item["private"]) ? "false" : "true");
 
-               $created = Temporal::convert($item["created"], "UTC", "UTC", 'Y-m-d\TH:i:s\Z');
+               $created = Temporal::convert($item["created"], "UTC", "UTC", Temporal::ATOM);
 
                // Detect a share element and do a reshare
                if (!$item['private'] && ($ret = self::isReshare($item["body"]))) {
@@ -3855,7 +3855,7 @@ class Diaspora
                $parent = $p[0];
 
                $text = html_entity_decode(bb2diaspora($item["body"]));
-               $created = Temporal::convert($item["created"], "UTC", "UTC", 'Y-m-d\TH:i:s\Z');
+               $created = Temporal::convert($item["created"], "UTC", "UTC", Temporal::ATOM);
 
                $comment = ["author" => self::myHandle($owner),
                                "guid" => $item["guid"],
@@ -4086,12 +4086,12 @@ class Diaspora
                        "author" => $cnv["creator"],
                        "guid" => $cnv["guid"],
                        "subject" => $cnv["subject"],
-                       "created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", 'Y-m-d\TH:i:s\Z'),
+                       "created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", Temporal::ATOM),
                        "participants" => $cnv["recips"]
                ];
 
                $body = bb2diaspora($item["body"]);
-               $created = Temporal::convert($item["created"], "UTC", "UTC", 'Y-m-d\TH:i:s\Z');
+               $created = Temporal::convert($item["created"], "UTC", "UTC", Temporal::ATOM);
 
                $msg = [
                        "author" => $myaddr,
@@ -4109,7 +4109,7 @@ class Diaspora
                                        "author" => $cnv["creator"],
                                        "guid" => $cnv["guid"],
                                        "subject" => $cnv["subject"],
-                                       "created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", 'Y-m-d\TH:i:s\Z'),
+                                       "created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", Temporal::ATOM),
                                        "participants" => $cnv["recips"],
                                        "message" => $msg];
 
index e2bb312e75dd4d2792c843db2827500c429f1140..b3c85f377e2de1be105924b14af0813b0a255e54 100644 (file)
@@ -1273,7 +1273,7 @@ class OStatus
                XML::addElement($doc, $root, "title", $title);
                XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"]));
                XML::addElement($doc, $root, "logo", $owner["photo"]);
-               XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", ATOM_TIME));
+               XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", Temporal::ATOM));
 
                $author = self::addAuthor($doc, $owner);
                $root->appendChild($author);
@@ -1539,7 +1539,7 @@ class OStatus
                XML::addElement($doc, $source, "link", "", ["rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]]);
                XML::addElement($doc, $source, "link", "", ["rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]]);
                XML::addElement($doc, $source, "icon", $contact["photo"]);
-               XML::addElement($doc, $source, "updated", Temporal::convert($contact["success_update"]."+00:00", "UTC", "UTC", ATOM_TIME));
+               XML::addElement($doc, $source, "updated", Temporal::convert($contact["success_update"]."+00:00", "UTC", "UTC", Temporal::ATOM));
 
                return $source;
        }
@@ -1923,8 +1923,8 @@ class OStatus
 
                XML::addElement($doc, $entry, "activity:verb", $verb);
 
-               XML::addElement($doc, $entry, "published", Temporal::convert($item["created"]."+00:00", "UTC", "UTC", ATOM_TIME));
-               XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"]."+00:00", "UTC", "UTC", ATOM_TIME));
+               XML::addElement($doc, $entry, "published", Temporal::convert($item["created"]."+00:00", "UTC", "UTC", Temporal::ATOM));
+               XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"]."+00:00", "UTC", "UTC", Temporal::ATOM));
        }
 
        /**
index 1ec77418030c75002de023558705641b5187ef49..8c465b4b66cd158e0df7f2bb782c3de9a8498ceb 100644 (file)
@@ -21,6 +21,7 @@ require_once 'include/text.php';
  */
 class Temporal
 {
+       const ATOM = 'Y-m-d\TH:i:s\Z';
 
        /**
         * @brief Two-level sort for timezones.
index 78fdd707e3b416eb2208acb6d7d8c2d266c7b16c..ff08ed09432cd487f88a26fb195196d06583f8af 100644 (file)
@@ -107,8 +107,8 @@ class OnePoll
                }
 
                $last_update = (($contact['last-update'] <= NULL_DATE)
-                       ? Temporal::convert('now - 7 days', 'UTC', 'UTC', ATOM_TIME)
-                       : Temporal::convert($contact['last-update'], 'UTC', 'UTC', ATOM_TIME)
+                       ? Temporal::convert('now - 7 days', 'UTC', 'UTC', Temporal::ATOM)
+                       : Temporal::convert($contact['last-update'], 'UTC', 'UTC', Temporal::ATOM)
                );
 
                // Update the contact entry