From 254a7f1c383919472e7e80754dba39dc8698a297 Mon Sep 17 00:00:00 2001 From: Ro Date: Mon, 19 Sep 2022 20:39:15 -0700 Subject: [PATCH] Scrubbed Moment from codebase Moment was still being used in some classes so found and replaced all those instances with Carbon and uninstalled the packaged from composer. --- brain/controller/DashControl.php | 3 +- brain/data/Member.php | 3 +- brain/data/Settings.php | 5 +-- brain/utility/Maintenance.php | 3 +- brain/utility/Setup.php | 4 ++- composer.json | 1 - composer.lock | 59 +------------------------------- 7 files changed, 13 insertions(+), 65 deletions(-) diff --git a/brain/controller/DashControl.php b/brain/controller/DashControl.php index e507a89..cf8c673 100644 --- a/brain/controller/DashControl.php +++ b/brain/controller/DashControl.php @@ -7,6 +7,7 @@ use brain\data\Session; use brain\data\Settings; use brain\data\Themes; use brain\utility\Setup; +use Carbon\Carbon; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Slim\Views\Twig; @@ -31,7 +32,7 @@ class DashControl $template = 'dash/settings.twig'; $member = Session::get('member'); $form_token = Session::get('form_token'); - $updated = new \Moment\Moment($settings['global']['last_backup']); + $updated = new Carbon($settings['global']['last_backup']); $pageOptions = [ 'title' => 'Dash Settings', 'private' => $settings['global']['private'], diff --git a/brain/data/Member.php b/brain/data/Member.php index 66ebc64..31e4cd8 100644 --- a/brain/data/Member.php +++ b/brain/data/Member.php @@ -2,6 +2,7 @@ namespace brain\data; +use Carbon\Carbon; use brain\utility\DocTools; use function _\find; @@ -38,7 +39,7 @@ class Member } $found[$key] = $data; //record time updated - $updated = new \Moment\Moment(); + $updated = Carbon::now(); $found['updated'] = $updated->format("Y-m-d\TH:i:sP"); $newFolks = []; array_push($newFolks, $found); diff --git a/brain/data/Settings.php b/brain/data/Settings.php index 7f050de..4b81b99 100644 --- a/brain/data/Settings.php +++ b/brain/data/Settings.php @@ -4,6 +4,7 @@ namespace brain\data; use brain\utility\DocTools; use brain\utility\Sorting; +use Carbon\Carbon; use function _\find; use function _\pull; @@ -67,8 +68,8 @@ class Settings $page['deleted'] ? ($page['deleted'] = 'true') : ($page['deleted'] = 'false'); - $updated = new \Moment\Moment(); - $created = new \Moment\Moment($page['rawCreated']); + $updated = Carbon::now(); + $created = new Carbon($page['rawCreated']); $page['created'] = $created->format("Y-m-d\TH:i:sP"); $page['updated'] = $updated->format("Y-m-d\TH:i:sP"); diff --git a/brain/utility/Maintenance.php b/brain/utility/Maintenance.php index eece1a2..f6a4469 100644 --- a/brain/utility/Maintenance.php +++ b/brain/utility/Maintenance.php @@ -2,6 +2,7 @@ namespace brain\utility; +use Carbon\Carbon; use brain\data\Settings; class Maintenance @@ -90,7 +91,7 @@ class Maintenance $zip->close(); //update settings file with latest back up date - $updated = new \Moment\Moment(); + $updated = Carbon::now(); Settings::updateGlobalData( 'last_backup', $updated->format("Y-m-d\TH:i:sP") diff --git a/brain/utility/Setup.php b/brain/utility/Setup.php index 80cd566..5d8c544 100644 --- a/brain/utility/Setup.php +++ b/brain/utility/Setup.php @@ -2,6 +2,8 @@ namespace brain\utility; +use Carbon\Carbon; + use function _\find; class SetUp @@ -33,7 +35,7 @@ class SetUp $pass = $body['new_member_pass']; $title = $body['new_member_title']; - $now = new \Moment\Moment(); + $now = Carbon::now(); //setup folks config $hash = password_hash($pass, PASSWORD_DEFAULT); $newFolks[0]['id'] = 0; diff --git a/composer.json b/composer.json index fccb845..b9c64e5 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,6 @@ "mnapoli/front-yaml": "^1.8", "lodash-php/lodash-php": "^0.0.7", "rbdwllr/reallysimplejwt": "^4.0", - "fightbulc/moment": "^1.33", "tgalopin/html-sanitizer": "^1.4", "phpmailer/phpmailer": "^6.4", "league/commonmark": "^2.1", diff --git a/composer.lock b/composer.lock index 698a8ac..3b9fa1a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5265e13cf91844428ed9c0e717a0f370", + "content-hash": "98a863eb9a0625835e203318bad0dac2", "packages": [ { "name": "dflydev/dot-access-data", @@ -187,63 +187,6 @@ }, "time": "2020-11-24T22:02:12+00:00" }, - { - "name": "fightbulc/moment", - "version": "1.33.0", - "source": { - "type": "git", - "url": "https://github.com/fightbulc/moment.php.git", - "reference": "435d68e481ab0a716358926fb51966e696d297e3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fightbulc/moment.php/zipball/435d68e481ab0a716358926fb51966e696d297e3", - "reference": "435d68e481ab0a716358926fb51966e696d297e3", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^5.5 || ^6.5 || ^7.5 || ^9.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Moment\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Tino Ehrich", - "email": "tino@bigpun.me", - "role": "developer" - } - ], - "description": "Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js", - "keywords": [ - "date", - "display", - "format", - "i18n", - "locale", - "manipulate", - "moment", - "parse", - "time", - "translation", - "validate" - ], - "support": { - "issues": "https://github.com/fightbulc/moment.php/issues", - "source": "https://github.com/fightbulc/moment.php/tree/1.33.0" - }, - "time": "2021-03-27T13:10:08+00:00" - }, { "name": "league/commonmark", "version": "2.3.5",