Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanil S. <135337715+sh1shd@users.noreply.github.com>2025-12-04 01:37:27 +0300
committerGitHub <noreply@github.com>2025-12-04 01:37:27 +0300
commit70f6d6b21a6761444c54898a6ed48793e72e7177 (patch)
tree1e9cdf81fe84da349b525016f3c499f0992426aa /web/assets/js/util/date-util.js
parente8c509c720267f6da34b9a43104f83f3dd77ef88 (diff)
chore: use `Intl` for date formatting (#3588)
* chore: use `Intl` for date formatting * fix: show last traffic reset * chore: use raw timestamps * fix: remove unnecessary import
Diffstat (limited to 'web/assets/js/util/date-util.js')
-rw-r--r--web/assets/js/util/date-util.js151
1 files changed, 0 insertions, 151 deletions
diff --git a/web/assets/js/util/date-util.js b/web/assets/js/util/date-util.js
deleted file mode 100644
index bbca1272..00000000
--- a/web/assets/js/util/date-util.js
+++ /dev/null
@@ -1,151 +0,0 @@
-const oneMinute = 1000 * 60; // MilliseConds in a Minute
-const oneHour = oneMinute * 60; // The milliseconds of one hour
-const oneDay = oneHour * 24; // The Number of MilliseConds A Day
-const oneWeek = oneDay * 7; // The milliseconds per week
-const oneMonth = oneDay * 30; // The milliseconds of a month
-
-/**
- * Decrease according to the number of days
- *
- * @param days to reduce the number of days to be reduced
- */
-Date.prototype.minusDays = function (days) {
- return this.minusMillis(oneDay * days);
-};
-
-/**
- * Increase according to the number of days
- *
- * @param days The number of days to be increased
- */
-Date.prototype.plusDays = function (days) {
- return this.plusMillis(oneDay * days);
-};
-
-/**
- * A few
- *
- * @param hours to be reduced
- */
-Date.prototype.minusHours = function (hours) {
- return this.minusMillis(oneHour * hours);
-};
-
-/**
- * Increase hourly
- *
- * @param hours to increase the number of hours
- */
-Date.prototype.plusHours = function (hours) {
- return this.plusMillis(oneHour * hours);
-};
-
-/**
- * Make reduction in minutes
- *
- * @param minutes to reduce the number of minutes
- */
-Date.prototype.minusMinutes = function (minutes) {
- return this.minusMillis(oneMinute * minutes);
-};
-
-/**
- * Add in minutes
- *
- * @param minutes to increase the number of minutes
- */
-Date.prototype.plusMinutes = function (minutes) {
- return this.plusMillis(oneMinute * minutes);
-};
-
-/**
- * Decrease in milliseconds
- *
- * @param millis to reduce the milliseconds
- */
-Date.prototype.minusMillis = function(millis) {
- let time = this.getTime() - millis;
- let newDate = new Date();
- newDate.setTime(time);
- return newDate;
-};
-
-/**
- * Add in milliseconds to increase
- *
- * @param millis to increase the milliseconds to increase
- */
-Date.prototype.plusMillis = function(millis) {
- let time = this.getTime() + millis;
- let newDate = new Date();
- newDate.setTime(time);
- return newDate;
-};
-
-/**
- * Setting time is 00: 00: 00.000 on the day
- */
-Date.prototype.setMinTime = function () {
- this.setHours(0);
- this.setMinutes(0);
- this.setSeconds(0);
- this.setMilliseconds(0);
- return this;
-};
-
-/**
- * Setting time is 23: 59: 59.999 on the same day
- */
-Date.prototype.setMaxTime = function () {
- this.setHours(23);
- this.setMinutes(59);
- this.setSeconds(59);
- this.setMilliseconds(999);
- return this;
-};
-
-/**
- * Formatting date
- */
-Date.prototype.formatDate = function () {
- return this.getFullYear() + "-" + NumberFormatter.addZero(this.getMonth() + 1) + "-" + NumberFormatter.addZero(this.getDate());
-};
-
-/**
- * Format time
- */
-Date.prototype.formatTime = function () {
- return NumberFormatter.addZero(this.getHours()) + ":" + NumberFormatter.addZero(this.getMinutes()) + ":" + NumberFormatter.addZero(this.getSeconds());
-};
-
-/**
- * Formatting date plus time
- *
- * @param split Date and time separation symbols, default is a space
- */
-Date.prototype.formatDateTime = function (split = ' ') {
- return this.formatDate() + split + this.formatTime();
-};
-
-class DateUtil {
- // String to date object
- static parseDate(str) {
- return new Date(str.replace(/-/g, '/'));
- }
-
- static formatMillis(millis) {
- return moment(millis).format('YYYY-M-D HH:mm:ss');
- }
-
- static firstDayOfMonth() {
- const date = new Date();
- date.setDate(1);
- date.setMinTime();
- return date;
- }
-
- static convertToJalalian(date) {
- return date && moment.isMoment(date) ? date.format('jYYYY/jMM/jDD HH:mm:ss') : null;
- }
-
-}