refactor: Replace moment with Dayjs (#346)

* dayjs

* locales added

* fix
This commit is contained in:
Rider21
2022-08-02 10:47:45 +03:00
committed by GitHub
parent fd6a907c5f
commit fa90d57eff
19 changed files with 108 additions and 88 deletions
+49 -43
View File
@@ -19,6 +19,7 @@
"@reduxjs/toolkit": "^1.7.2",
"buffer": "^6.0.3",
"cheerio": "^1.0.0-rc.10",
"dayjs": "^1.11.4",
"expo": "^41.0.1",
"expo-document-picker": "^9.2.4",
"expo-file-system": "~11.0.2",
@@ -33,7 +34,6 @@
"expo-web-browser": "~9.1.0",
"i18n-js": "^3.8.0",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"prop-types": "^15.7.2",
"qs": "^6.10.1",
"react": "16.13.1",
@@ -4087,7 +4087,6 @@
"version": "0.66.15",
"resolved": "https://registry.npmjs.org/@types/react-native/-/react-native-0.66.15.tgz",
"integrity": "sha512-qNK3LZhNpSd2Hdr0OFdvQ/VOb1qcjNhmw96LsOtxIN+1RtXHO/1dVzxYUlWnKMCtV+E5WSaWM703c9Q7gG9tyg==",
"dev": true,
"dependencies": {
"@types/react": "*"
}
@@ -6350,9 +6349,9 @@
"integrity": "sha512-2u44ZG2OcNUO9HDp/Jl8C07x6pU/eTR3ncV91SiK3dhG9TWvRVsCoJw14Ckx5DgWkzGA3waZWO3d7pgqpUI/XA=="
},
"node_modules/dayjs": {
"version": "1.10.5",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.5.tgz",
"integrity": "sha512-BUFis41ikLz+65iH6LHQCDm4YPMj5r1YFLdupPIyM4SGcXMmtiLQ7U37i+hGS8urIuqe7I/ou3IS1jVc4nbN4g=="
"version": "1.11.4",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.4.tgz",
"integrity": "sha512-Zj/lPM5hOvQ1Bf7uAvewDaUcsJoI6JmNqmHhHl3nyumwe0XHwt8sWdOVAPACJzCebL8gQCi+K49w7iKWnGwX9g=="
},
"node_modules/debug": {
"version": "4.3.4",
@@ -11495,14 +11494,6 @@
"resolved": "https://registry.npmjs.org/mockdate/-/mockdate-3.0.5.tgz",
"integrity": "sha512-iniQP4rj1FhBdBYS/+eQv7j1tadJ9lJtdzgOpvsOHng/GbcDh2Fhdeq+ZRldrPYdXvCyfFUmFeEwEGXZB5I/AQ=="
},
"node_modules/moment": {
"version": "2.29.4",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
"engines": {
"node": "*"
}
},
"node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@@ -18511,7 +18502,8 @@
"@jsamr/react-native-li": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@jsamr/react-native-li/-/react-native-li-2.3.1.tgz",
"integrity": "sha512-Qbo4NEj48SQ4k8FZJHFE2fgZDKTWaUGmVxcIQh3msg5JezLdTMMHuRRDYctfdHI6L0FZGObmEv3haWbIvmol8w=="
"integrity": "sha512-Qbo4NEj48SQ4k8FZJHFE2fgZDKTWaUGmVxcIQh3msg5JezLdTMMHuRRDYctfdHI6L0FZGObmEv3haWbIvmol8w==",
"requires": {}
},
"@native-html/css-processor": {
"version": "1.11.0",
@@ -18952,7 +18944,8 @@
"@react-native-community/clipboard": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/@react-native-community/clipboard/-/clipboard-1.5.1.tgz",
"integrity": "sha512-AHAmrkLEH5UtPaDiRqoULERHh3oNv7Dgs0bTC0hO5Z2GdNokAMPT5w8ci8aMcRemcwbtdHjxChgtjbeA38GBdA=="
"integrity": "sha512-AHAmrkLEH5UtPaDiRqoULERHh3oNv7Dgs0bTC0hO5Z2GdNokAMPT5w8ci8aMcRemcwbtdHjxChgtjbeA38GBdA==",
"requires": {}
},
"@react-native-community/eslint-config": {
"version": "3.0.1",
@@ -19023,17 +19016,20 @@
"@react-native-community/masked-view": {
"version": "0.1.11",
"resolved": "https://registry.npmjs.org/@react-native-community/masked-view/-/masked-view-0.1.11.tgz",
"integrity": "sha512-rQfMIGSR/1r/SyN87+VD8xHHzDYeHaJq6elOSCAD+0iLagXkSI2pfA0LmSXP21uw5i3em7GkkRjfJ8wpqWXZNw=="
"integrity": "sha512-rQfMIGSR/1r/SyN87+VD8xHHzDYeHaJq6elOSCAD+0iLagXkSI2pfA0LmSXP21uw5i3em7GkkRjfJ8wpqWXZNw==",
"requires": {}
},
"@react-native-community/slider": {
"version": "4.1.12",
"resolved": "https://registry.npmjs.org/@react-native-community/slider/-/slider-4.1.12.tgz",
"integrity": "sha512-CiuLZ2orueBiWHYxfaJF57jQY6HY2Q3z5pdAE4MKH8EqIImr/jgDJrJ/UxOVZHK1Ng9P+XlGIKfVIcuWZ6guuA=="
"integrity": "sha512-CiuLZ2orueBiWHYxfaJF57jQY6HY2Q3z5pdAE4MKH8EqIImr/jgDJrJ/UxOVZHK1Ng9P+XlGIKfVIcuWZ6guuA==",
"requires": {}
},
"@react-native-picker/picker": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/@react-native-picker/picker/-/picker-2.4.1.tgz",
"integrity": "sha512-1XWy3IQgwr7MWd30KdY1iUh2gQZD+JiotN1ifj/ptFUYKon/0UFwngKQaWCO/CP/FdLl20/huSSLwKedYrdMMA=="
"integrity": "sha512-1XWy3IQgwr7MWd30KdY1iUh2gQZD+JiotN1ifj/ptFUYKon/0UFwngKQaWCO/CP/FdLl20/huSSLwKedYrdMMA==",
"requires": {}
},
"@react-native/assets": {
"version": "1.0.0",
@@ -19065,7 +19061,8 @@
"@react-navigation/elements": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@react-navigation/elements/-/elements-1.2.1.tgz",
"integrity": "sha512-EnmAbKMsptrliRKf95rdgS6BhMjML+mIns06+G1Vdih6BrEo7/0iytThUv3WBf99AI76dyEq/cqLUwHPiFzXWg=="
"integrity": "sha512-EnmAbKMsptrliRKf95rdgS6BhMjML+mIns06+G1Vdih6BrEo7/0iytThUv3WBf99AI76dyEq/cqLUwHPiFzXWg==",
"requires": {}
},
"@react-navigation/material-bottom-tabs": {
"version": "6.0.9",
@@ -19260,7 +19257,6 @@
"version": "0.66.15",
"resolved": "https://registry.npmjs.org/@types/react-native/-/react-native-0.66.15.tgz",
"integrity": "sha512-qNK3LZhNpSd2Hdr0OFdvQ/VOb1qcjNhmw96LsOtxIN+1RtXHO/1dVzxYUlWnKMCtV+E5WSaWM703c9Q7gG9tyg==",
"dev": true,
"requires": {
"@types/react": "*"
}
@@ -19659,7 +19655,8 @@
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
"integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
"dev": true
"dev": true,
"requires": {}
},
"aggregate-error": {
"version": "3.1.0",
@@ -19904,7 +19901,8 @@
"babel-core": {
"version": "7.0.0-bridge.0",
"resolved": "https://registry.npmjs.org/babel-core/-/babel-core-7.0.0-bridge.0.tgz",
"integrity": "sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg=="
"integrity": "sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg==",
"requires": {}
},
"babel-eslint": {
"version": "10.1.0",
@@ -20906,9 +20904,9 @@
"integrity": "sha512-2u44ZG2OcNUO9HDp/Jl8C07x6pU/eTR3ncV91SiK3dhG9TWvRVsCoJw14Ckx5DgWkzGA3waZWO3d7pgqpUI/XA=="
},
"dayjs": {
"version": "1.10.5",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.5.tgz",
"integrity": "sha512-BUFis41ikLz+65iH6LHQCDm4YPMj5r1YFLdupPIyM4SGcXMmtiLQ7U37i+hGS8urIuqe7I/ou3IS1jVc4nbN4g=="
"version": "1.11.4",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.4.tgz",
"integrity": "sha512-Zj/lPM5hOvQ1Bf7uAvewDaUcsJoI6JmNqmHhHl3nyumwe0XHwt8sWdOVAPACJzCebL8gQCi+K49w7iKWnGwX9g=="
},
"debug": {
"version": "4.3.4",
@@ -21485,7 +21483,8 @@
"version": "22.4.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-22.4.1.tgz",
"integrity": "sha512-gcLfn6P2PrFAVx3AobaOzlIEevpAEf9chTpFZz7bYfc7pz8XRv7vuKTIE4hxPKZSha6XWKKplDQ0x9Pq8xX2mg==",
"dev": true
"dev": true,
"requires": {}
},
"eslint-plugin-prettier": {
"version": "3.1.2",
@@ -21549,7 +21548,8 @@
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.3.0.tgz",
"integrity": "sha512-XslZy0LnMn+84NEG9jSGR6eGqaZB3133L8xewQo3fQagbQuGt7a63gf+P1NGKZavEYEC3UXaWEAA/AqDkuN6xA==",
"dev": true
"dev": true,
"requires": {}
},
"eslint-plugin-react-native": {
"version": "3.11.0",
@@ -24891,11 +24891,6 @@
"resolved": "https://registry.npmjs.org/mockdate/-/mockdate-3.0.5.tgz",
"integrity": "sha512-iniQP4rj1FhBdBYS/+eQv7j1tadJ9lJtdzgOpvsOHng/GbcDh2Fhdeq+ZRldrPYdXvCyfFUmFeEwEGXZB5I/AQ=="
},
"moment": {
"version": "2.29.4",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@@ -25819,7 +25814,8 @@
"ws": {
"version": "7.4.6",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
"integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A=="
"integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==",
"requires": {}
}
}
},
@@ -26178,17 +26174,20 @@
"react-native-device-info": {
"version": "8.4.7",
"resolved": "https://registry.npmjs.org/react-native-device-info/-/react-native-device-info-8.4.7.tgz",
"integrity": "sha512-I0z7FfbtxKW5+1wWE7L1bzy0iuiQzgUNVUrvpQoVQSz/BpC9kNIwZokC8O3HpUJDkFVr2Bhd5WO3tISzS7OXxw=="
"integrity": "sha512-I0z7FfbtxKW5+1wWE7L1bzy0iuiQzgUNVUrvpQoVQSz/BpC9kNIwZokC8O3HpUJDkFVr2Bhd5WO3tISzS7OXxw==",
"requires": {}
},
"react-native-easing-gradient": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/react-native-easing-gradient/-/react-native-easing-gradient-1.0.0.tgz",
"integrity": "sha512-wkFPbjDLvySHKzqkCYxD8vTgKLdlgch9AL8wkO+liJuukwVXeD2sDqtPPsMKqX6hWK+Ebg8shjIeavNfoOLy7w=="
"integrity": "sha512-wkFPbjDLvySHKzqkCYxD8vTgKLdlgch9AL8wkO+liJuukwVXeD2sDqtPPsMKqX6hWK+Ebg8shjIeavNfoOLy7w==",
"requires": {}
},
"react-native-fast-image": {
"version": "8.5.11",
"resolved": "https://registry.npmjs.org/react-native-fast-image/-/react-native-fast-image-8.5.11.tgz",
"integrity": "sha512-cNW4bIJg3nvKaheG8vGMfqCt5LMWX9MS5+wMudgKIHbGO51spRr4sgnlhVgwHLcZ5aeNOVJ8CPRxDIWKRq/0QA=="
"integrity": "sha512-cNW4bIJg3nvKaheG8vGMfqCt5LMWX9MS5+wMudgKIHbGO51spRr4sgnlhVgwHLcZ5aeNOVJ8CPRxDIWKRq/0QA==",
"requires": {}
},
"react-native-fit-image": {
"version": "1.5.5",
@@ -26229,7 +26228,8 @@
"react-native-iphone-x-helper": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz",
"integrity": "sha512-HOf0jzRnq2/aFUcdCJ9w9JGzN3gdEg0zFE4FyYlp4jtidqU03D5X7ZegGKfT1EWteR0gPBGp9ye5T5FvSWi9Yg=="
"integrity": "sha512-HOf0jzRnq2/aFUcdCJ9w9JGzN3gdEg0zFE4FyYlp4jtidqU03D5X7ZegGKfT1EWteR0gPBGp9ye5T5FvSWi9Yg==",
"requires": {}
},
"react-native-markdown-display": {
"version": "7.0.0-alpha.2",
@@ -26245,7 +26245,8 @@
"react-native-pager-view": {
"version": "5.4.9",
"resolved": "https://registry.npmjs.org/react-native-pager-view/-/react-native-pager-view-5.4.9.tgz",
"integrity": "sha512-D6tzxpwMGdl6CXgtskGWhKRc5cJakCazESRGt7PkqnpyiH3N35ft1KmR82pCSQetAFlytFiToeu3a/dG5CELvA=="
"integrity": "sha512-D6tzxpwMGdl6CXgtskGWhKRc5cJakCazESRGt7PkqnpyiH3N35ft1KmR82pCSQetAFlytFiToeu3a/dG5CELvA==",
"requires": {}
},
"react-native-paper": {
"version": "4.10.1",
@@ -26303,7 +26304,8 @@
"react-native-safe-area-context": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/react-native-safe-area-context/-/react-native-safe-area-context-3.2.0.tgz",
"integrity": "sha512-k2Nty4PwSnrg9HwrYeeE+EYqViYJoOFwEy9LxL5RIRfoqxAq/uQXNGwpUg2/u4gnKpBbEPa9eRh15KKMe/VHkA=="
"integrity": "sha512-k2Nty4PwSnrg9HwrYeeE+EYqViYJoOFwEy9LxL5RIRfoqxAq/uQXNGwpUg2/u4gnKpBbEPa9eRh15KKMe/VHkA==",
"requires": {}
},
"react-native-screens": {
"version": "3.9.0",
@@ -26317,7 +26319,8 @@
"react-freeze": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/react-freeze/-/react-freeze-1.0.0.tgz",
"integrity": "sha512-yQaiOqDmoKqks56LN9MTgY06O0qQHgV4FUrikH357DydArSZHQhl0BJFqGKIZoTqi8JizF9Dxhuk1FIZD6qCaw=="
"integrity": "sha512-yQaiOqDmoKqks56LN9MTgY06O0qQHgV4FUrikH357DydArSZHQhl0BJFqGKIZoTqi8JizF9Dxhuk1FIZD6qCaw==",
"requires": {}
}
}
},
@@ -26329,7 +26332,8 @@
"react-native-tab-view": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-3.1.1.tgz",
"integrity": "sha512-M5pRN6utQfytKWoKlKVzg5NbkYu308qNoW1khGTtEOTs1k14p2dHJ/BWOJoJYHKbPVUyZldbG9MFT7gUl4YHnw=="
"integrity": "sha512-M5pRN6utQfytKWoKlKVzg5NbkYu308qNoW1khGTtEOTs1k14p2dHJ/BWOJoJYHKbPVUyZldbG9MFT7gUl4YHnw==",
"requires": {}
},
"react-native-tts": {
"version": "4.1.0",
@@ -26569,12 +26573,14 @@
"redux-persist": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/redux-persist/-/redux-persist-6.0.0.tgz",
"integrity": "sha512-71LLMbUq2r02ng2We9S215LtPu3fY0KgaGE0k8WRgl6RkqxtGfl7HUozz1Dftwsb0D/5mZ8dwAaPbtnzfvbEwQ=="
"integrity": "sha512-71LLMbUq2r02ng2We9S215LtPu3fY0KgaGE0k8WRgl6RkqxtGfl7HUozz1Dftwsb0D/5mZ8dwAaPbtnzfvbEwQ==",
"requires": {}
},
"redux-thunk": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.4.1.tgz",
"integrity": "sha512-OOYGNY5Jy2TWvTL1KgAlVy6dcx3siPJ1wTq741EPyUKfn6W6nChdICjZwCd0p8AZBs5kWpZlbkXW2nE/zjUa+Q=="
"integrity": "sha512-OOYGNY5Jy2TWvTL1KgAlVy6dcx3siPJ1wTq741EPyUKfn6W6nChdICjZwCd0p8AZBs5kWpZlbkXW2nE/zjUa+Q==",
"requires": {}
},
"regenerate": {
"version": "1.4.2",
+1 -1
View File
@@ -26,6 +26,7 @@
"@reduxjs/toolkit": "^1.7.2",
"buffer": "^6.0.3",
"cheerio": "^1.0.0-rc.10",
"dayjs": "^1.11.4",
"expo": "^41.0.1",
"expo-document-picker": "^9.2.4",
"expo-file-system": "~11.0.2",
@@ -40,7 +41,6 @@
"expo-web-browser": "~9.1.0",
"i18n-js": "^3.8.0",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"prop-types": "^15.7.2",
"qs": "^6.10.1",
"react": "16.13.1",
+2 -2
View File
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { StyleSheet, SectionList, Text } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import moment from 'moment';
import dayjs from 'dayjs';
import { Portal } from 'react-native-paper';
import {
@@ -150,7 +150,7 @@ const HistoryScreen = () => {
<Text
style={[styles.dateHeader, { color: theme.textColorSecondary }]}
>
{moment(date).calendar(null, dateFormats)}
{dayjs(date).calendar(null, dateFormats)}
</Text>
)}
renderItem={({ item }) => (
@@ -1,7 +1,7 @@
import React, { useMemo } from 'react';
import { Pressable, StyleSheet, Text, View } from 'react-native';
import moment from 'moment';
import dayjs from 'dayjs';
import FastImage from 'react-native-fast-image';
import { IconButtonV2 } from '../../../../components';
@@ -58,7 +58,7 @@ const HistoryCard: React.FC<HistoryCardProps> = ({
const chapterNoAndTime = useMemo(
() =>
`Chapter ${parseChapterNumber(chapterName)} • ${moment(historyTimeRead)
`Chapter ${parseChapterNumber(chapterName)} • ${dayjs(historyTimeRead)
.format('LT')
.toUpperCase()}`,
[chapterName, historyTimeRead],
@@ -1,7 +1,7 @@
import { StyleSheet, Text, View } from 'react-native';
import React, { useEffect, useState } from 'react';
import { useBatteryLevel } from 'react-native-device-info';
import moment from 'moment';
import dayjs from 'dayjs';
import { useReaderSettings, useSettingsV1 } from '@redux/hooks';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -55,7 +55,7 @@ const BottomInfoBar: React.FC<BottomInfoBarProps> = ({ scrollPercentage }) => {
) : null}
{showBatteryAndTime ? (
<Text style={{ color: textColor }}>
{moment(currentTime).format('LT')}
{dayjs(currentTime).format('LT')}
</Text>
) : null}
</View>
+3 -3
View File
@@ -1,6 +1,6 @@
import React from 'react';
import { useNavigation } from '@react-navigation/native';
import moment from 'moment';
import dayjs from 'dayjs';
import { RefreshControl, SectionList, StyleSheet, Text } from 'react-native';
import {
@@ -178,7 +178,7 @@ const UpdatesScreen = () => {
<Text
style={[styles.dateHeader, { color: theme.textColorSecondary }]}
>
{moment(date).calendar(null, dateFormats)}
{dayjs(date).calendar(null, dateFormats)}
</Text>
)}
renderItem={({ item }) => (
@@ -219,7 +219,7 @@ const LastUpdateTime: React.FC<{ lastUpdateTime: Date; theme: ThemeType }> = ({
theme,
}) => (
<Text style={[styles.lastUpdateTime, { color: theme.textColorSecondary }]}>
{`${getString('updatesScreen.lastUpdatedAt')} ${moment(
{`${getString('updatesScreen.lastUpdatedAt')} ${dayjs(
lastUpdateTime,
).fromNow()}`}
</Text>
+2 -2
View File
@@ -6,7 +6,7 @@ import BackgroundService from 'react-native-background-actions';
import { restoreLibrary } from '../../../database/queries/NovelQueries';
import { getLibrary } from '../../../database/queries/LibraryQueries';
import { showToast } from '../../../hooks/showToast';
import moment from 'moment';
import dayjs from 'dayjs';
const sleep = time => new Promise(resolve => setTimeout(() => resolve(), time));
@@ -33,7 +33,7 @@ export const createBackup = async () => {
const uri = permissions.directoryUri;
const date = moment().format('YYYY-MM-DD');
const date = dayjs().format('YYYY-MM-DD');
const fileName = 'lnreader_backup_' + date;
+2 -2
View File
@@ -1,5 +1,5 @@
import * as cheerio from 'cheerio';
import moment from 'moment';
import dayjs from 'dayjs';
const sourceId = 27;
@@ -73,7 +73,7 @@ const parseNovelAndChapters = async novelUrl => {
loadedCheerio('#chapterlist')
.find('li')
.each(function () {
const releaseDate = moment(
const releaseDate = dayjs(
loadedCheerio(this).find('.chapterdate').text(),
).format('LL');
const chapterName = loadedCheerio(this).find('.chapternum').text();
+2 -2
View File
@@ -1,5 +1,5 @@
import * as cheerio from 'cheerio';
import moment from 'moment';
import dayjs from 'dayjs';
const baseUrl = 'https://www.novelpassion.com/';
@@ -91,7 +91,7 @@ const parseNovelAndChapters = async novelUrl => {
const chapterName = loadedCheerio(this).find('span.sp1').text();
let releaseDate = loadedCheerio(this).find('i.sp2').text();
releaseDate = moment(new Date(releaseDate)).format('MM/DD/YY');
releaseDate = dayjs(new Date(releaseDate)).format('L');
const chapterUrl = loadedCheerio(this)
.find('a')
+3 -3
View File
@@ -1,5 +1,5 @@
import * as cheerio from 'cheerio';
import moment from 'moment';
import dayjs from 'dayjs';
import { showToast } from '../../hooks/showToast';
const sourceId = 51;
@@ -120,7 +120,7 @@ const parseNovelAndChapters = async novelUrl => {
releaseDate.setDate(releaseDate.getDate() - timeAgo);
}
releaseDate = moment(releaseDate).format('MM/DD/YY');
releaseDate = dayjs(releaseDate).format('L');
const chapterUrl = loadedCheerio(this)
.find('a')
@@ -164,7 +164,7 @@ const parseNovelAndChapters = async novelUrl => {
// releaseDate.setDate(releaseDate.getDate() - timeAgo);
// }
// releaseDate = moment(releaseDate).format("MM/DD/YY");
// releaseDate = dayjs(releaseDate).format("L");
// const chapterUrl = $(this)
// .find("a")
+2 -2
View File
@@ -1,5 +1,5 @@
import * as cheerio from 'cheerio';
import moment from 'moment';
import dayjs from 'dayjs';
const sourceId = 49;
@@ -99,7 +99,7 @@ const parseNovelAndChapters = async novelUrl => {
releaseDate.setDate(releaseDate.getDate() - timeAgo);
}
releaseDate = moment(releaseDate).format('MM/DD/YY');
releaseDate = dayjs(releaseDate).format('L');
const chapterUrl = loadedCheerio(this)
.find('a')
+2 -2
View File
@@ -1,4 +1,4 @@
import moment from 'moment';
import dayjs from 'dayjs';
export const parseMadaraDate = date => {
let releaseDate = date;
@@ -21,7 +21,7 @@ export const parseMadaraDate = date => {
releaseDate.setMonth(releaseDate.getMonth() - timeAgo);
}
releaseDate = moment(releaseDate).format('LL');
releaseDate = dayjs(releaseDate).format('LL');
}
return releaseDate;
+2 -2
View File
@@ -1,4 +1,4 @@
import moment from 'moment';
import dayjs from 'dayjs';
import * as cheerio from 'cheerio';
import { defaultCoverUri, Status } from '../../helpers/constants';
import { parseMadaraDate } from '../../helpers/parseDate';
@@ -160,7 +160,7 @@ class MadaraScraper {
* Insert current date
*/
releaseDate = moment().format('LL');
releaseDate = dayjs().format('LL');
}
let chapterUrl = loadedCheerio(this).find('a').attr('href').split('/');
+2 -2
View File
@@ -1,4 +1,4 @@
import moment from 'moment';
import dayjs from 'dayjs';
import * as cheerio from 'cheerio';
import { defaultTo } from 'lodash';
import { Status } from '../helpers/constants';
@@ -92,7 +92,7 @@ const parseNovelAndChapters = async novelUrl => {
novelChapters.push({
chapterName: chapter.name,
chapterUrl: chapter.url,
releaseDate: moment(parseInt(chapter.changed_at) * 1000).format('LLL'),
releaseDate: dayjs(parseInt(chapter.changed_at) * 1000).format('LLL'),
}),
),
);
+2 -2
View File
@@ -1,4 +1,4 @@
import moment from 'moment';
import dayjs from 'dayjs';
import * as cheerio from 'cheerio';
import { defaultTo } from 'lodash';
import { Status } from '../helpers/constants';
@@ -128,7 +128,7 @@ const parseNovelAndChapters = async novelUrl => {
chaptersJson.chapters.list.map(item => {
const chapterName =
`Том ${item.chapter_volume} Глава ${item.chapter_number} ${item.chapter_name}`?.trim();
const releaseDate = moment(item.chapter_created_at).format('LLL');
const releaseDate = dayjs(item.chapter_created_at).format('LLL');
const chapterUrl = `${baseUrl}/${novelSlug}/v${item.chapter_volume}/c${item.chapter_number}`;
chapters.push({ chapterName, releaseDate, chapterUrl });
+2 -2
View File
@@ -1,4 +1,4 @@
import moment from 'moment';
import dayjs from 'dayjs';
import * as cheerio from 'cheerio';
import { defaultTo } from 'lodash';
import { htmlToText } from '../helpers/htmlToText';
@@ -68,7 +68,7 @@ const parseNovelAndChapters = async novelUrl => {
json.props.pageProps.book.chapters.map(item => {
const chapterName = item.title;
const releaseDate = moment(item.publishedAt).format('LLL');
const releaseDate = dayjs(item.publishedAt).format('LLL');
const chapterUrl = baseUrl + item.url;
if (!item.isDonate || item.isUserPaid) {
+2 -2
View File
@@ -2,7 +2,7 @@ import { FilterInputs } from '../types/filterTypes';
import { htmlToText } from '../helpers/htmlToText';
import { Status } from '../helpers/constants';
import { defaultTo } from 'lodash';
import moment from 'moment';
import dayjs from 'dayjs';
const sourceId = 116;
const sourceName = 'Renovels';
@@ -93,7 +93,7 @@ const parseNovelAndChapters = async novelUrl => {
volumes.content.map(item => {
const chapterName =
`Том ${item.tome} Глава ${item.chapter} ${item.name}`?.trim();
const releaseDate = moment(item.upload_date).format('LLL');
const releaseDate = dayjs(item.upload_date).format('LLL');
const chapterUrl = baseUrl + '/api/titles/chapters/' + item.id + '/';
if (!item.is_paid || item.is_bought) {
+6 -2
View File
@@ -1,4 +1,5 @@
import { FilterInputs } from '../types/filterTypes';
import { htmlToText } from '../helpers/htmlToText';
import { Status } from '../helpers/constants';
import * as cheerio from 'cheerio';
import { defaultTo } from 'lodash';
@@ -83,11 +84,14 @@ const parseNovelAndChapters = async novelUrl => {
.trim();
novel.novelCover =
baseUrl + loadedCheerio('div[class="images"] > div img').attr('src');
novel.summary = loadedCheerio('#Info > div:nth-child(3)').text().trim();
novel.summary = loadedCheerio('#Info > div:nth-child(3)').html();
novel.genre = [];
let chapters = [];
if (novel?.summary) {
novel.summary = htmlToText(novel.summary);
}
let chapters = [];
loadedCheerio('div[class="span5"] > p').each(function () {
switch (loadedCheerio(this).find('strong').text()) {
case 'Автор:':
+20 -10
View File
@@ -1,15 +1,25 @@
import * as Localization from 'expo-localization';
import moment from 'moment';
import * as dayjs from 'dayjs';
import i18n from 'i18n-js';
import 'moment/locale/es';
import 'moment/locale/tr';
import 'moment/locale/ru';
import 'moment/locale/ar';
import 'moment/locale/uk';
import 'moment/locale/pt';
import 'moment/locale/de';
import 'moment/locale/it';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import relativeTime from 'dayjs/plugin/relativeTime';
import calendar from 'dayjs/plugin/calendar';
dayjs.extend(customParseFormat);
dayjs.extend(localizedFormat);
dayjs.extend(relativeTime);
dayjs.extend(calendar);
import 'dayjs/locale/es';
import 'dayjs/locale/tr';
import 'dayjs/locale/ru';
import 'dayjs/locale/ar';
import 'dayjs/locale/uk';
import 'dayjs/locale/pt';
import 'dayjs/locale/de';
import 'dayjs/locale/it';
import 'dayjs/locale/zh';
import en from './languages/en/strings.json';
import es from './languages/es/strings.json';
@@ -27,6 +37,6 @@ import { StringMap } from './types';
i18n.fallbacks = true;
i18n.translations = { en, es, tr, ru, ar, uk, pt, de, it, zh };
i18n.locale = Localization.locale;
moment.locale(Localization.locale);
dayjs.locale(Localization.locale);
export const getString = (stringKey: keyof StringMap) => i18n.t(stringKey);