Skip to content

Commit

Permalink
feat(snippets): show time for today updated & full date for other sni…
Browse files Browse the repository at this point in the history
…ppets
  • Loading branch information
antonreshetov committed Apr 15, 2022
1 parent f5f50e6 commit 3724a5b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -38,6 +38,7 @@
"@vueuse/core": "^8.1.2",
"ace-builds": "^1.4.14",
"axios": "^0.26.1",
"date-fns": "^2.28.0",
"electron-store": "^8.0.1",
"fs-extra": "^10.0.1",
"highlight.js": "^11.5.1",
Expand Down
9 changes: 6 additions & 3 deletions src/renderer/components/snippets/SnippetListItem.vue
Expand Up @@ -43,6 +43,7 @@ import { onClickOutside } from '@vueuse/core'
import { computed, ref } from 'vue'
import type { SystemFolderAlias } from '@shared/types/renderer/sidebar'
import { useTagStore } from '@/store/tags'
import { isToday, format } from 'date-fns'
interface Props {
id: string
Expand Down Expand Up @@ -208,9 +209,11 @@ const onClickContextMenu = async () => {
snippetStore.selectedMultiple = []
}
const dateFormat = computed(() =>
new Intl.DateTimeFormat('ru').format(props.date)
)
const dateFormat = computed(() => {
const date = new Date(props.date)
if (isToday(date)) return format(date, 'HH:mm')
return format(date, 'dd.MM.yyyy')
})
const onDragStart = (e: DragEvent) => {
if (snippetStore.selectedIds.length) {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -4499,6 +4499,11 @@ dashdash@^1.12.0:
dependencies:
assert-plus "^1.0.0"

date-fns@^2.28.0:
version "2.28.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.28.0.tgz#9570d656f5fc13143e50c975a3b6bbeb46cd08b2"
integrity sha512-8d35hViGYx/QH0icHYCeLmsLmMUheMmTyV9Fcm6gvNwdw31yXXH+O85sOBJ+OLnLQMKZowvpKb6FgMIQjcpvQw==

debounce-fn@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/debounce-fn/-/debounce-fn-4.0.0.tgz#ed76d206d8a50e60de0dd66d494d82835ffe61c7"
Expand Down

0 comments on commit 3724a5b

Please sign in to comment.