Skip to content

Commit

Permalink
UI / UX: display dir item time stat; display date / time in local format
Browse files Browse the repository at this point in the history
Fixes #33
Fixes #136
  • Loading branch information
aleksey-hoffman committed Aug 28, 2021
1 parent 52cb2a5 commit 05d1786
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/components/DirItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Copyright © 2021 - present Aleksey Hoffman. All rights reserved.

<!-- card::date-->
<div class="dir-item-card__date">
{{$utils.formatDateTime(source.stat.ctime, 'D MMM YYYY')}}
{{getLocalDateTime({stat: 'ctime'})}}
</div>

<!-- {type: (directory|directory-symlink)} -->
Expand Down Expand Up @@ -327,6 +327,12 @@ export default {
}
},
methods: {
getLocalDateTime (params) {
return this.$utils.getLocalDateTime(
this.source.stat[params.stat],
this.$store.state.storageData.settings.dateTime
)
},
async loadThumbHandler (path) {
if (this.source.path === path) {
await this.loadThumb()
Expand Down
9 changes: 6 additions & 3 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ export default new Vuex.Store({
time: {
lastSearchScan: null
},
dateTime: {
month: 'short'
},
lastRecordedAppVersion: null,
firstTimeActions: {
appLaunch: true,
Expand Down Expand Up @@ -4147,19 +4150,19 @@ export default new Vuex.Store({
{
propName: 'dateCreated',
title: localize.get('text_created'),
value: utils.formatDateTime(item.stat.birthtime, 'D MMM YYYY'),
value: utils.getLocalDateTime(item.stat.birthtime, store.state.storageData.settings.dateTime),
tooltip: `${localize.get('tooltip_text_to_copy')}: ${copyShortcut}`
},
{
propName: 'dateModified',
title: localize.get('text_modified'),
value: utils.formatDateTime(item.stat.mtime, 'D MMM YYYY'),
value: utils.getLocalDateTime(item.stat.mtime, store.state.storageData.settings.dateTime),
tooltip: `${localize.get('tooltip_text_to_copy')}: ${copyShortcut}`
},
{
propName: 'dateChanged',
title: localize.get('text_changed'),
value: utils.formatDateTime(item.stat.ctime, 'D MMM YYYY'),
value: utils.getLocalDateTime(item.stat.ctime, store.state.storageData.settings.dateTime),
tooltip: `${localize.get('tooltip_text_to_copy')}: ${copyShortcut}`
},
{
Expand Down
20 changes: 19 additions & 1 deletion src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const electronRemote = require('@electron/remote')
const getSystemRulesForPaths = require('./systemRules').paths
const systemRulesForPaths = getSystemRulesForPaths()
const mainWindow = electronRemote.getCurrentWindow()
const detectedLocale = electronRemote.app.getLocale().toLowerCase()
const detectedLocale = electronRemote?.app?.getLocale()?.toLowerCase() || 'en'

const colorUtils = new ColorUtils()

Expand Down Expand Up @@ -449,6 +449,24 @@ export default {
if (!date) { return 'unknown' }
return dayjs(date).locale(detectedLocale).format(format)
},
getLocalDateTime (date, options = {}) {
try {
return new Intl.DateTimeFormat(detectedLocale, {
...{
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric'
},
...options
})
.format(date)
}
catch (error) {
return 'unknown'
}
},
getCSSProperty (property, element = '#app') {
const node = document.querySelector(element)
return node.computedStyleMap().get(property)
Expand Down

0 comments on commit 05d1786

Please sign in to comment.