From 415e0a7b5a91503a54c79909c361eddf370afeb6 Mon Sep 17 00:00:00 2001 From: advplyr Date: Wed, 6 Jul 2022 19:18:27 -0500 Subject: [PATCH] Remove dependency date-and-time --- package-lock.json | 5 ----- package.json | 1 - server/Logger.js | 2 +- server/libs/dateAndTime/LICENSE | 21 +++++++++++++++++++++ server/libs/dateAndTime/index.js | 17 +++++++++++++++++ server/managers/PlaybackSessionManager.js | 2 +- server/objects/Backup.js | 2 +- server/objects/DailyLog.js | 2 +- server/objects/FeedEpisode.js | 2 +- server/objects/PlaybackSession.js | 2 +- server/routers/ApiRouter.js | 2 +- server/scanner/LibraryScan.js | 2 +- 12 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 server/libs/dateAndTime/LICENSE create mode 100644 server/libs/dateAndTime/index.js diff --git a/package-lock.json b/package-lock.json index d3d3e5fc..91043d26 100644 --- a/package-lock.json +++ b/package-lock.json @@ -264,11 +264,6 @@ "readable-stream": "^3.4.0" } }, - "date-and-time": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/date-and-time/-/date-and-time-2.3.1.tgz", - "integrity": "sha512-OaIRmSJXifwEN21rMVVDs0Kz8uhJ3wWPYd86atkRiqN54liaMQYEbbrgjZQea75YXOBWL4ZFb3rG/waenw1TEg==" - }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", diff --git a/package.json b/package.json index 4f72599f..9fdcbb99 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "dependencies": { "archiver": "^5.3.0", "axios": "^0.26.1", - "date-and-time": "^2.3.1", "express": "^4.17.1", "htmlparser2": "^8.0.1", "socket.io": "^4.4.1", diff --git a/server/Logger.js b/server/Logger.js index 376e08c8..2bdce9ac 100644 --- a/server/Logger.js +++ b/server/Logger.js @@ -1,4 +1,4 @@ -const date = require('date-and-time') +const date = require('./libs/dateAndTime') const { LogLevel } = require('./utils/constants') class Logger { diff --git a/server/libs/dateAndTime/LICENSE b/server/libs/dateAndTime/LICENSE new file mode 100644 index 00000000..08dc7cf2 --- /dev/null +++ b/server/libs/dateAndTime/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 KNOWLEDGECODE + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/server/libs/dateAndTime/index.js b/server/libs/dateAndTime/index.js new file mode 100644 index 00000000..32249afb --- /dev/null +++ b/server/libs/dateAndTime/index.js @@ -0,0 +1,17 @@ +/* + date-and-time (c) KNOWLEDGECODE | MIT +*/ +'use strict';(function(p,m){"object"===typeof exports&&"undefined"!==typeof module?module.exports=m():"function"===typeof define&&define.amd?define(m):(p="undefined"!==typeof globalThis?globalThis:p||self,p.date=m())})(this,function(){var p={},m={},r="en",t={MMMM:"January February March April May June July August September October November December".split(" "),MMM:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),dddd:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "), +ddd:"Sun Mon Tue Wed Thu Fri Sat".split(" "),dd:"Su Mo Tu We Th Fr Sa".split(" "),A:["AM","PM"]},w={YYYY:function(a){return("000"+a.getFullYear()).slice(-4)},YY:function(a){return("0"+a.getFullYear()).slice(-2)},Y:function(a){return""+a.getFullYear()},MMMM:function(a){return this.res.MMMM[a.getMonth()]},MMM:function(a){return this.res.MMM[a.getMonth()]},MM:function(a){return("0"+(a.getMonth()+1)).slice(-2)},M:function(a){return""+(a.getMonth()+1)},DD:function(a){return("0"+a.getDate()).slice(-2)}, +D:function(a){return""+a.getDate()},HH:function(a){return("0"+a.getHours()).slice(-2)},H:function(a){return""+a.getHours()},A:function(a){return this.res.A[11c&&(d=h,c=l.length);return{value:d,length:c}},pre:function(a){return a},res:t},n=function(a,b,d,c){var h={},g;for(g in a)h[g]= +a[g];for(g in b||{})!!d^!!h[g]||(h[g]=b[g]);c&&(h.res=c);return h},f={_formatter:w,_parser:x};f.compile=function(a){for(var b=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,d,c=[a];d=b.exec(a);)c[c.length]=d[0];return c};f.format=function(a,b,d){var c=this||e;b="string"===typeof b?c.compile(b):b;var h=a.getTimezoneOffset();a=c.addMinutes(a,d?h:0);c=c._formatter;var g="";a.getTimezoneOffset=function(){return d?0:h};for(var l=1,u=b.length,k;la.Y?22801:1,d||~c._parser.find(b,"ZZ").value?new Date(Date.UTC(a.Y,a.M,a.D,a.H,a.m+a.Z,a.s,a.S)):new Date(a.Y,a.M,a.D,a.H,a.m,a.s,a.S)):new Date(NaN)};f.isValid=function(a,b){var d=this||e;a="string"===typeof a?d.preparse(a,b):a;d=[31,28+d.isLeapYear(a.Y)|0,31,30,31,30,31,31,30,31,30,31][a.M-1];return!(1>a._index||1> +a._length||a._index-a._length||1>a._match||1>a.Y||9999a.M||12a.D||a.D>d||0>a.H||23a.m||59a.s||59a.S||999a.Z||720