Merge pull request #377 from myl7/date

This commit is contained in:
Spencer Woo
2022-02-08 21:54:33 +08:00
committed by GitHub
5 changed files with 19 additions and 13 deletions
+2 -5
View File
@@ -7,6 +7,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import DownloadButtonGroup from '../DownloadBtnGtoup' import DownloadButtonGroup from '../DownloadBtnGtoup'
import { DownloadBtnContainer, PreviewContainer } from './Containers' import { DownloadBtnContainer, PreviewContainer } from './Containers'
import { LoadingIcon } from '../Loading' import { LoadingIcon } from '../Loading'
import { formatModifiedDateTime } from '../../utils/fileDetails'
enum PlayerState { enum PlayerState {
Loading, Loading,
@@ -36,11 +37,7 @@ const AudioPreview: FC<{ file: OdFileObject }> = ({ file }) => {
<div className="flex w-full flex-col space-y-2"> <div className="flex w-full flex-col space-y-2">
<div>{file.name}</div> <div>{file.name}</div>
<div className="pb-4 text-sm text-gray-500"> <div className="pb-4 text-sm text-gray-500">
Last modified:{' '} Last modified: {formatModifiedDateTime(file.lastModifiedDateTime)}
{new Date(file.lastModifiedDateTime).toLocaleString(undefined, {
dateStyle: 'short',
timeStyle: 'short',
})}
</div> </div>
<ReactAudioPlayer <ReactAudioPlayer
+5
View File
@@ -57,4 +57,9 @@ module.exports = {
link: 'https://t.me/realSpencerWoo', link: 'https://t.me/realSpencerWoo',
}, },
], ],
// This is a day.js-style datetime format string to format datetimes in the app. Ref to
// https://day.js.org/docs/en/display/format for detailed specification. The default value is ISO 8601 full datetime
// without timezone and replacing T with space.
datetimeFormat: 'YYYY-MM-DD HH:mm:ss',
} }
+1
View File
@@ -21,6 +21,7 @@
"axios": "^0.25.0", "axios": "^0.25.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"dayjs": "^1.10.7",
"emoji-regex": "^10.0.0", "emoji-regex": "^10.0.0",
"flv.js": "^1.6.2", "flv.js": "^1.6.2",
"ioredis": "^4.28.2", "ioredis": "^4.28.2",
+6
View File
@@ -22,6 +22,7 @@ specifiers:
axios: ^0.25.0 axios: ^0.25.0
cors: ^2.8.5 cors: ^2.8.5
crypto-js: ^4.1.1 crypto-js: ^4.1.1
dayjs: ^1.10.7
emoji-regex: ^10.0.0 emoji-regex: ^10.0.0
eslint: 8.8.0 eslint: 8.8.0
eslint-config-next: 12.0.10 eslint-config-next: 12.0.10
@@ -68,6 +69,7 @@ dependencies:
axios: 0.25.0 axios: 0.25.0
cors: 2.8.5 cors: 2.8.5
crypto-js: 4.1.1 crypto-js: 4.1.1
dayjs: 1.10.7
emoji-regex: 10.0.0 emoji-regex: 10.0.0
flv.js: 1.6.2 flv.js: 1.6.2
ioredis: 4.28.3 ioredis: 4.28.3
@@ -988,6 +990,10 @@ packages:
resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==} resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==}
dev: true dev: true
/dayjs/1.10.7:
resolution: {integrity: sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig==}
dev: false
/debounce-promise/3.1.2: /debounce-promise/3.1.2:
resolution: {integrity: sha512-rZHcgBkbYavBeD9ej6sP56XfG53d51CD4dnaw989YX/nZ/ZJfgRx/9ePKmTNiUiyQvh4mtrMoS3OAWW+yoYtpg==} resolution: {integrity: sha512-rZHcgBkbYavBeD9ej6sP56XfG53d51CD4dnaw989YX/nZ/ZJfgRx/9ePKmTNiUiyQvh4mtrMoS3OAWW+yoYtpg==}
dev: false dev: false
+5 -8
View File
@@ -1,3 +1,7 @@
import dayjs from 'dayjs'
import siteConfig from '../config/site.config'
/** /**
* Convert raw bits file/folder size into a human readable string * Convert raw bits file/folder size into a human readable string
* *
@@ -20,12 +24,5 @@ export const humanFileSize = (size: number) => {
* @returns Human readable form of the file or folder last modified date * @returns Human readable form of the file or folder last modified date
*/ */
export const formatModifiedDateTime = (lastModifedDateTime: string) => { export const formatModifiedDateTime = (lastModifedDateTime: string) => {
return new Date(lastModifedDateTime).toLocaleString('en-US', { return dayjs(lastModifedDateTime).format(siteConfig.datetimeFormat)
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
hour12: false,
})
} }