|
@@ -2,18 +2,21 @@
|
|
* @Author: NMTuan
|
|
* @Author: NMTuan
|
|
* @Email: NMTuan@qq.com
|
|
* @Email: NMTuan@qq.com
|
|
* @Date: 2024-02-19 22:13:33
|
|
* @Date: 2024-02-19 22:13:33
|
|
- * @LastEditTime: 2024-02-19 23:06:51
|
|
|
|
|
|
+ * @LastEditTime: 2024-02-22 13:17:11
|
|
* @LastEditors: NMTuan
|
|
* @LastEditors: NMTuan
|
|
* @Description:
|
|
* @Description:
|
|
- * @FilePath: /timeNow/stores/date.ts
|
|
|
|
|
|
+ * @FilePath: \timeNow\stores\date.ts
|
|
*/
|
|
*/
|
|
import { defineStore } from 'pinia'
|
|
import { defineStore } from 'pinia'
|
|
|
|
|
|
export const useDateStore = defineStore('date', () => {
|
|
export const useDateStore = defineStore('date', () => {
|
|
|
|
+ const settingStore = useSettingStore()
|
|
|
|
+
|
|
const year = ref('1970')
|
|
const year = ref('1970')
|
|
const month = ref('01')
|
|
const month = ref('01')
|
|
const date = ref('01')
|
|
const date = ref('01')
|
|
const hour = ref('00')
|
|
const hour = ref('00')
|
|
|
|
+ const hour12 = ref('00')
|
|
const minute = ref('00')
|
|
const minute = ref('00')
|
|
const second = ref('00')
|
|
const second = ref('00')
|
|
const millisecond = ref(0)
|
|
const millisecond = ref(0)
|
|
@@ -24,7 +27,13 @@ export const useDateStore = defineStore('date', () => {
|
|
year.value = today.getFullYear().toString()
|
|
year.value = today.getFullYear().toString()
|
|
month.value = (today.getMonth() + 1).toString().padStart(2, '0')
|
|
month.value = (today.getMonth() + 1).toString().padStart(2, '0')
|
|
date.value = today.getDate().toString().padStart(2, '0')
|
|
date.value = today.getDate().toString().padStart(2, '0')
|
|
|
|
+
|
|
hour.value = today.getHours().toString().padStart(2, '0')
|
|
hour.value = today.getHours().toString().padStart(2, '0')
|
|
|
|
+ let h = today.getHours()
|
|
|
|
+ if (!settingStore.hour24 && h > 12) {
|
|
|
|
+ h = h % 12
|
|
|
|
+ }
|
|
|
|
+ hour12.value = h.toString().padStart(2, '0')
|
|
minute.value = today.getMinutes().toString().padStart(2, '0')
|
|
minute.value = today.getMinutes().toString().padStart(2, '0')
|
|
second.value = today.getSeconds().toString().padStart(2, '0')
|
|
second.value = today.getSeconds().toString().padStart(2, '0')
|
|
millisecond.value = today.getMilliseconds()
|
|
millisecond.value = today.getMilliseconds()
|
|
@@ -36,6 +45,7 @@ export const useDateStore = defineStore('date', () => {
|
|
month,
|
|
month,
|
|
date,
|
|
date,
|
|
hour,
|
|
hour,
|
|
|
|
+ hour12,
|
|
minute,
|
|
minute,
|
|
second,
|
|
second,
|
|
millisecond,
|
|
millisecond,
|