Переход на dayjs
This commit is contained in:
@@ -60,7 +60,7 @@ class PasteTextPage {
|
|||||||
|
|
||||||
calcTitle(event) {
|
calcTitle(event) {
|
||||||
if (this.bookTitle == '') {
|
if (this.bookTitle == '') {
|
||||||
this.bookTitle = `Из буфера обмена ${utils.formatDate(new Date(), 'noDate')}`;
|
this.bookTitle = `Из буфера обмена ${utils.dateFormat(new Date())}`;
|
||||||
if (event) {
|
if (event) {
|
||||||
let text = event.clipboardData.getData('text');
|
let text = event.clipboardData.getData('text');
|
||||||
this.bookTitle += ': ' + _.compact([
|
this.bookTitle += ': ' + _.compact([
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ class ReaderDialogs {
|
|||||||
async showWhatsNew() {
|
async showWhatsNew() {
|
||||||
const whatsNew = versionHistory[0];
|
const whatsNew = versionHistory[0];
|
||||||
if (this.showWhatsNewDialog &&
|
if (this.showWhatsNewDialog &&
|
||||||
whatsNew.showUntil >= utils.formatDate(new Date(), 'coDate') &&
|
whatsNew.showUntil >= utils.dateFormat(new Date(), 'YYYY-MM-DD') &&
|
||||||
this.whatsNewHeader != this.whatsNewContentHash) {
|
this.whatsNewHeader != this.whatsNewContentHash) {
|
||||||
await utils.sleep(2000);
|
await utils.sleep(2000);
|
||||||
this.whatsNewContent = 'Версия ' + this.whatsNewHeader + whatsNew.content;
|
this.whatsNewContent = 'Версия ' + this.whatsNewHeader + whatsNew.content;
|
||||||
@@ -139,8 +139,8 @@ class ReaderDialogs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async showDonation() {
|
async showDonation() {
|
||||||
const today = utils.formatDate(new Date(), 'coMonth');
|
const today = utils.dateFormat(new Date(), 'MM');
|
||||||
|
console.log(today);
|
||||||
if ((this.mode == 'omnireader' || this.mode == 'liberama') && this.showDonationDialog && this.donationRemindDate != today) {
|
if ((this.mode == 'omnireader' || this.mode == 'liberama') && this.showDonationDialog && this.donationRemindDate != today) {
|
||||||
await utils.sleep(3000);
|
await utils.sleep(3000);
|
||||||
this.donationVisible = true;
|
this.donationVisible = true;
|
||||||
@@ -158,7 +158,7 @@ class ReaderDialogs {
|
|||||||
|
|
||||||
donationDialogRemind() {
|
donationDialogRemind() {
|
||||||
this.donationVisible = false;
|
this.donationVisible = false;
|
||||||
this.commit('reader/setDonationRemindDate', utils.formatDate(new Date(), 'coMonth'));
|
this.commit('reader/setDonationRemindDate', utils.dateFormat(new Date(), 'MM'));
|
||||||
}
|
}
|
||||||
|
|
||||||
makeDonation() {
|
makeDonation() {
|
||||||
|
|||||||
@@ -367,10 +367,10 @@ class RecentBooksPage {
|
|||||||
|
|
||||||
let d = new Date();
|
let d = new Date();
|
||||||
d.setTime(book.touchTime);
|
d.setTime(book.touchTime);
|
||||||
const touchTime = utils.formatDate(d);
|
const touchTime = utils.dateFormat(d, 'DD.MM.YYYY HH:mm');
|
||||||
const loadTimeRaw = (book.loadTime ? book.loadTime : 0);//book.addTime);
|
const loadTimeRaw = (book.loadTime ? book.loadTime : 0);//book.addTime);
|
||||||
d.setTime(loadTimeRaw);
|
d.setTime(loadTimeRaw);
|
||||||
const loadTime = utils.formatDate(d);
|
const loadTime = utils.dateFormat(d, 'DD.MM.YYYY HH:mm');
|
||||||
|
|
||||||
let readPart = 0;
|
let readPart = 0;
|
||||||
let perc = '';
|
let perc = '';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
import baseX from 'base-x';
|
import baseX from 'base-x';
|
||||||
import PAKO from 'pako';
|
import PAKO from 'pako';
|
||||||
import {Buffer} from 'safe-buffer';
|
import {Buffer} from 'safe-buffer';
|
||||||
@@ -35,24 +36,6 @@ export function randomHexString(len) {
|
|||||||
return Buffer.from(randomArray(len)).toString('hex');
|
return Buffer.from(randomArray(len)).toString('hex');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatDate(d, format) {
|
|
||||||
if (!format)
|
|
||||||
format = 'normal';
|
|
||||||
|
|
||||||
switch (format) {
|
|
||||||
case 'normal':
|
|
||||||
return `${d.getDate().toString().padStart(2, '0')}.${(d.getMonth() + 1).toString().padStart(2, '0')}.${d.getFullYear()} ` +
|
|
||||||
`${d.getHours().toString().padStart(2, '0')}:${d.getMinutes().toString().padStart(2, '0')}`;
|
|
||||||
case 'coDate':
|
|
||||||
return `${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, '0')}-${d.getDate().toString().padStart(2, '0')}`;
|
|
||||||
case 'coMonth':
|
|
||||||
return `${(d.getMonth() + 1).toString().padStart(2, '0')}`;
|
|
||||||
case 'noDate':
|
|
||||||
return `${d.getDate().toString().padStart(2, '0')}.${(d.getMonth() + 1).toString().padStart(2, '0')}.${d.getFullYear()}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fallbackCopyTextToClipboard(text) {
|
export function fallbackCopyTextToClipboard(text) {
|
||||||
let textArea = document.createElement('textarea');
|
let textArea = document.createElement('textarea');
|
||||||
textArea.value = text;
|
textArea.value = text;
|
||||||
@@ -416,3 +399,7 @@ export function resizeImage(dataUrl, toWidth, toHeight, quality = 0.9) {
|
|||||||
export function makeDonation() {
|
export function makeDonation() {
|
||||||
window.open('https://donatty.com/liberama', '_blank');
|
window.open('https://donatty.com/liberama', '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function dateFormat(date, format = 'DD.MM.YYYY') {
|
||||||
|
return dayjs(date).format(format);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user