Merge branch 'main' into file-info-redesign
This commit is contained in:
commit
48cd1b375a
|
@ -21,6 +21,7 @@ import { FlexWrapper } from './Container';
|
|||
import { Typography } from '@mui/material';
|
||||
import { GalleryContext } from 'pages/gallery';
|
||||
import { SpecialPadding } from 'styles/SpecialPadding';
|
||||
import { formatDate } from 'utils/time/format';
|
||||
|
||||
const A_DAY = 24 * 60 * 60 * 1000;
|
||||
const FOOTER_HEIGHT = 90;
|
||||
|
@ -304,22 +305,17 @@ export function PhotoList({
|
|||
)
|
||||
) {
|
||||
currentDate = item.metadata.creationTime / 1000;
|
||||
const dateTimeFormat = new Intl.DateTimeFormat('en-IN', {
|
||||
weekday: 'short',
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
});
|
||||
|
||||
timeStampList.push({
|
||||
itemType: ITEM_TYPE.TIME,
|
||||
date: isSameDay(new Date(currentDate), new Date())
|
||||
? 'Today'
|
||||
? constants.TODAY
|
||||
: isSameDay(
|
||||
new Date(currentDate),
|
||||
new Date(Date.now() - A_DAY)
|
||||
)
|
||||
? 'Yesterday'
|
||||
: dateTimeFormat.format(currentDate),
|
||||
? constants.YESTERDAY
|
||||
: formatDate(currentDate),
|
||||
id: currentDate.toString(),
|
||||
});
|
||||
timeStampList.push({
|
||||
|
|
|
@ -59,9 +59,15 @@ export default function Recover() {
|
|||
setFieldError
|
||||
) => {
|
||||
try {
|
||||
recoveryKey = recoveryKey
|
||||
.trim()
|
||||
.split(' ')
|
||||
.map((part) => part.trim())
|
||||
.filter((part) => !!part)
|
||||
.join(' ');
|
||||
// check if user is entering mnemonic recovery key
|
||||
if (recoveryKey.trim().indexOf(' ') > 0) {
|
||||
if (recoveryKey.trim().split(' ').length !== 24) {
|
||||
if (recoveryKey.indexOf(' ') > 0) {
|
||||
if (recoveryKey.split(' ').length !== 24) {
|
||||
throw new Error('recovery code should have 24 words');
|
||||
}
|
||||
recoveryKey = bip39.mnemonicToEntropy(recoveryKey);
|
||||
|
|
|
@ -52,9 +52,15 @@ export default function Recover() {
|
|||
setFieldError
|
||||
) => {
|
||||
try {
|
||||
recoveryKey = recoveryKey
|
||||
.trim()
|
||||
.split(' ')
|
||||
.map((part) => part.trim())
|
||||
.filter((part) => !!part)
|
||||
.join(' ');
|
||||
// check if user is entering mnemonic recovery key
|
||||
if (recoveryKey.trim().indexOf(' ') > 0) {
|
||||
if (recoveryKey.trim().split(' ').length !== 24) {
|
||||
if (recoveryKey.indexOf(' ') > 0) {
|
||||
if (recoveryKey.split(' ').length !== 24) {
|
||||
throw new Error('recovery code should have 24 words');
|
||||
}
|
||||
recoveryKey = bip39.mnemonicToEntropy(recoveryKey);
|
||||
|
|
|
@ -835,6 +835,9 @@ const englishConstants = {
|
|||
'A new version of ente has been released, but it cannot be automatically downloaded and installed.',
|
||||
DOWNLOAD_AND_INSTALL: 'Download and install',
|
||||
IGNORE_THIS_VERSION: 'Ignore this version',
|
||||
TODAY: 'Today',
|
||||
YESTERDAY: 'Yesterday',
|
||||
AT: 'at',
|
||||
};
|
||||
|
||||
export default englishConstants;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import constants from 'utils/strings/constants';
|
||||
|
||||
export function formatDateFull(date: number | Date) {
|
||||
const dateTimeFormat1 = new Intl.DateTimeFormat('en-US', {
|
||||
weekday: 'short',
|
||||
|
@ -33,6 +35,18 @@ export function formatDate(date: number | Date) {
|
|||
.join(' ');
|
||||
}
|
||||
|
||||
export function formatDateTimeShort(date: number | Date) {
|
||||
const dateTimeFormat = new Intl.DateTimeFormat('en-US', {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
});
|
||||
|
||||
return dateTimeFormat.format(date);
|
||||
}
|
||||
|
||||
export function formatTime(date: number | Date) {
|
||||
const timeFormat = new Intl.DateTimeFormat('en-IN', {
|
||||
timeStyle: 'short',
|
||||
|
@ -41,24 +55,13 @@ export function formatTime(date: number | Date) {
|
|||
}
|
||||
|
||||
export function formatDateTimeFull(dateTime: number | Date): string {
|
||||
return [formatDateFull(dateTime), 'at', formatTime(dateTime)].join(' ');
|
||||
return [formatDateFull(dateTime), constants.AT, formatTime(dateTime)].join(
|
||||
' '
|
||||
);
|
||||
}
|
||||
|
||||
export function formatDateTime(dateTime: number | Date): string {
|
||||
return [formatDate(dateTime), 'at', formatTime(dateTime)].join(' ');
|
||||
}
|
||||
|
||||
export function formatDateTimeShort(date: number | Date) {
|
||||
const dateTimeFormat = new Intl.DateTimeFormat('en-IN', {
|
||||
weekday: 'short',
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
});
|
||||
const timeFormat = new Intl.DateTimeFormat('en-IN', {
|
||||
timeStyle: 'short',
|
||||
});
|
||||
return `${dateTimeFormat.format(date)} ${timeFormat.format(date)}`;
|
||||
return [formatDate(dateTime), constants.AT, formatTime(dateTime)].join(' ');
|
||||
}
|
||||
|
||||
export function formatDateRelative(date: number) {
|
||||
|
|
Loading…
Reference in a new issue