Skip to content

Commit 3724a5b

Browse files
committed
feat(snippets): show time for today updated & full date for other snippets
1 parent f5f50e6 commit 3724a5b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@vueuse/core": "^8.1.2",
3939
"ace-builds": "^1.4.14",
4040
"axios": "^0.26.1",
41+
"date-fns": "^2.28.0",
4142
"electron-store": "^8.0.1",
4243
"fs-extra": "^10.0.1",
4344
"highlight.js": "^11.5.1",

src/renderer/components/snippets/SnippetListItem.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { onClickOutside } from '@vueuse/core'
4343
import { computed, ref } from 'vue'
4444
import type { SystemFolderAlias } from '@shared/types/renderer/sidebar'
4545
import { useTagStore } from '@/store/tags'
46+
import { isToday, format } from 'date-fns'
4647
4748
interface Props {
4849
id: string
@@ -208,9 +209,11 @@ const onClickContextMenu = async () => {
208209
snippetStore.selectedMultiple = []
209210
}
210211
211-
const dateFormat = computed(() =>
212-
new Intl.DateTimeFormat('ru').format(props.date)
213-
)
212+
const dateFormat = computed(() => {
213+
const date = new Date(props.date)
214+
if (isToday(date)) return format(date, 'HH:mm')
215+
return format(date, 'dd.MM.yyyy')
216+
})
214217
215218
const onDragStart = (e: DragEvent) => {
216219
if (snippetStore.selectedIds.length) {

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4499,6 +4499,11 @@ dashdash@^1.12.0:
44994499
dependencies:
45004500
assert-plus "^1.0.0"
45014501

4502+
date-fns@^2.28.0:
4503+
version "2.28.0"
4504+
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.28.0.tgz#9570d656f5fc13143e50c975a3b6bbeb46cd08b2"
4505+
integrity sha512-8d35hViGYx/QH0icHYCeLmsLmMUheMmTyV9Fcm6gvNwdw31yXXH+O85sOBJ+OLnLQMKZowvpKb6FgMIQjcpvQw==
4506+
45024507
debounce-fn@^4.0.0:
45034508
version "4.0.0"
45044509
resolved "https://registry.yarnpkg.com/debounce-fn/-/debounce-fn-4.0.0.tgz#ed76d206d8a50e60de0dd66d494d82835ffe61c7"

0 commit comments

Comments
 (0)