Skip to content

Commit

Permalink
- Fix current local date format
Browse files Browse the repository at this point in the history
- Add warning to merge collections
- Change format of date tag in save tabs
  • Loading branch information
Rustem Mussabekov committed Feb 18, 2025
1 parent 6111f42 commit 94ce852
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app",
"version": "5.6.71",
"version": "5.6.72",
"description": "All-in-one bookmark manager",
"author": "Rustem Mussabekov",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/co/collections/items/selectMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class CollectionsSelectMode extends React.Component {
onMergeSelected = async()=>{
const { selectMode: { ids }, actions: { mergeSelected } } = this.props

if (await Confirm(`${t.s('areYouSure')}\n${t.s('merge')} ${ids.length} ${t.s('collectionsCount')}`))
if (await Confirm(`${t.s('areYouSure')}\n${t.s('merge')} ${ids.length} ${t.s('collectionsCount')}.\nAll selected collections will be merged into one.`))
mergeSelected()
}

Expand Down
3 changes: 2 additions & 1 deletion src/modules/format/date/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export * from './short'
export * from './long'
export * from './longTime'
export * from './month'
export * from './shortTime'
export * from './shortTime'
export * from './numeric'
3 changes: 1 addition & 2 deletions src/modules/format/date/long.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react'
import t from '~t'
import { parseDate } from './parse'
import dateFnsFormat from 'date-fns/format'

let _format
function getFormat() {
if (!_format)
_format = new Intl.DateTimeFormat(
t.currentLang,
undefined,
{
year: 'numeric',
month: 'long',
Expand Down
3 changes: 1 addition & 2 deletions src/modules/format/date/longTime.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react'
import t from '~t'
import { parseDate } from './parse'
import dateFnsFormat from 'date-fns/format'

let _format
function getFormat() {
if (!_format)
_format = new Intl.DateTimeFormat(
t.currentLang,
undefined,
{
hour12: new Date().toLocaleTimeString().toString().match(/am|pm/i) ? true : false,
year: 'numeric',
Expand Down
3 changes: 1 addition & 2 deletions src/modules/format/date/month.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react'
import t from '~t'
import { parseDate } from './parse'
import dateFnsFormat from 'date-fns/format'

let _format
function getFormat() {
if (!_format)
_format = new Intl.DateTimeFormat(
t.currentLang,
undefined,
{
year: 'numeric',
month: 'long',
Expand Down
39 changes: 39 additions & 0 deletions src/modules/format/date/numeric.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react'
import { parseDate } from './parse'
import dateFnsFormat from 'date-fns/format'

let _format
function getFormat() {
if (!_format)
_format = new Intl.DateTimeFormat(
undefined,
{
year: 'numeric',
month: 'numeric',
day: 'numeric',
}
).format

return _format
}

export const numericDate = (original) => {
let d
try{ d = parseDate(original) } catch(e){}

try{
return getFormat()(d)
}catch(e){}

try{
return dateFnsFormat(d, 'P')
}catch(e){}

return ''
}

export const NumericDate = React.memo(
function({ date }) {
return numericDate(date)
}
)
3 changes: 1 addition & 2 deletions src/modules/format/date/short.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import t from '~t'
import isToday from 'date-fns/isToday'
import isThisYear from 'date-fns/isThisYear'
import dateFnsFormat from 'date-fns/format'
Expand All @@ -17,7 +16,7 @@ function getFormat(type) {
default: params = { year: 'numeric', month: 'short', day: 'numeric' }; break;
}

_formats[type] = new Intl.DateTimeFormat(t.currentLang, { hour12, ...params }).format
_formats[type] = new Intl.DateTimeFormat(undefined, { hour12, ...params }).format
}

return _formats[type]
Expand Down
3 changes: 1 addition & 2 deletions src/modules/format/date/shortTime.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react'
import t from '~t'
import { parseDate } from './parse'
import dateFnsFormat from 'date-fns/format'

let _format
function getFormat() {
if (!_format)
_format = new Intl.DateTimeFormat(
t.currentLang,
undefined,
{
hour12: new Date().toLocaleTimeString().toString().match(/am|pm/i) ? true : false,
year: 'numeric',
Expand Down
4 changes: 2 additions & 2 deletions src/routes/extension/tabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react'
import { useParams } from 'react-router-dom'
import Screen from '~co/screen/basic'
import { Layout, Separator } from '~co/common/form'
import { longDate } from '~modules/format/date'
import { numericDate } from '~modules/format/date'

import useTabs, { preload } from './useTabs'
import useSubmit from './useSubmit'
Expand All @@ -19,7 +19,7 @@ export default function ExtensionTabsScreen() {
const params = useParams()
const [tabs, setTabs] = useTabs()
const [collectionId, setCollectionId] = useState(params.collectionId)
const [tags, setTags] = useState(()=>[longDate(new Date()).replace(/,/g, ' ')])
const [tags, setTags] = useState(()=>[numericDate(new Date())])
const [close, setClose] = useState(true)
const {onSubmit, loading} = useSubmit({ tabs, collectionId, tags, close })

Expand Down

0 comments on commit 94ce852

Please sign in to comment.