+
diff --git a/src/components/UiInlineStack.vue b/src/components/UiInlineStack.vue
new file mode 100644
index 0000000..886b06e
--- /dev/null
+++ b/src/components/UiInlineStack.vue
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/lib/date-fns/absDuration.ts b/src/lib/date-fns/absDuration.ts
new file mode 100644
index 0000000..8853ddd
--- /dev/null
+++ b/src/lib/date-fns/absDuration.ts
@@ -0,0 +1,12 @@
+import type { Duration } from 'date-fns'
+
+export function absDuration(duration: Duration): Duration {
+ const result: Duration = {}
+ const entries = Object.entries(duration)
+
+ for (const [key, value] of entries) {
+ result[key as keyof Duration] = Math.abs(value)
+ }
+
+ return result
+}
diff --git a/src/lib/date-fns/formatDuration.ts b/src/lib/date-fns/formatDuration.ts
index 0710d2e..19de4fa 100644
--- a/src/lib/date-fns/formatDuration.ts
+++ b/src/lib/date-fns/formatDuration.ts
@@ -3,5 +3,5 @@ import type { Duration } from 'date-fns'
export function formatDuration(duration: Duration): string {
const hours = (duration.hours ?? '0').toString().padStart(2, '0')
const minutes = (duration.minutes ?? '0').toString().padStart(2, '0')
- return `${hours}:${minutes}`
+ return `${hours}:${minutes}h`
}
diff --git a/src/lib/date-fns/getDurationSign.ts b/src/lib/date-fns/getDurationSign.ts
new file mode 100644
index 0000000..0330dc2
--- /dev/null
+++ b/src/lib/date-fns/getDurationSign.ts
@@ -0,0 +1,14 @@
+import type { Duration } from 'date-fns';
+
+export function getDurationSign(duration: Duration): -1 | 0 | 1 {
+ const values = Object.values(duration) as number[]
+ const sum = values.reduce((sum, value) => sum + value, 0)
+
+ if (sum < 0) {
+ return -1
+ }
+ if (sum > 0) {
+ return 1
+ }
+ return 0
+}
\ No newline at end of file
diff --git a/src/stores/times.ts b/src/stores/times.ts
index 80765e9..80bb629 100644
--- a/src/stores/times.ts
+++ b/src/stores/times.ts
@@ -38,8 +38,6 @@ export const useTimesStore = defineStore('times', () => {
}
}
- days.sort(sortDates())
-
const today = new Date(
currentTime.value.getFullYear(),
currentTime.value.getMonth(),
@@ -56,13 +54,12 @@ export const useTimesStore = defineStore('times', () => {
const selectedDay = ref
(new Date())
const selectedDayIsToday = computed((): boolean => {
- return isSameDay(currentTime.value, selectedDay.value)
+ return isToday(selectedDay.value)
})
const timestampsOfSelectedDay = computed((): Date[] => {
const result = timestamps.value.filter((timestamp) => isSameDay(timestamp, selectedDay.value))
- result.sort(sortDates(true))
- return result
+ return result.toSorted(sortDates(true))
})
const workTimeOfSelectedDay = computed((): Duration => {
@@ -106,6 +103,10 @@ export const useTimesStore = defineStore('times', () => {
return add(currentTime.value, remainingWorkTimeOfSelectedDay.value)
})
+ const workTimeOfSelectedDayIsLessThan8Hours = computed(
+ () => (workTimeOfSelectedDay.value.hours ?? 0) < 8,
+ )
+
return {
currentTime,
timestamps,
@@ -117,6 +118,7 @@ export const useTimesStore = defineStore('times', () => {
breakTimeOfSelectedDay,
remainingWorkTimeOfSelectedDay,
timeAfterRemainingWorkTimeOfSelectedDay,
+ workTimeOfSelectedDayIsLessThan8Hours,
importData,
setSelectedDay(day: Date) {
@@ -126,6 +128,7 @@ export const useTimesStore = defineStore('times', () => {
addTime(time: Date) {
if (Number.isNaN(time.getTime())) return
timestamps.value.push(time)
+ timestamps.value.sort(sortDates())
},
addCurrentTime() {
@@ -142,7 +145,7 @@ export const useTimesStore = defineStore('times', () => {
},
getDayInfo(day: Date): DayInfo {
- const filteredTimestamps = timestamps.value.filter((time) => isSameDay(time, day))
+ const filteredTimestamps = timestamps.value.filter((time) => isSameDay(time, day)).toSorted(sortDates(true))
const timestampsCount = filteredTimestamps.length
if (isToday(day)) {
diff --git a/tsconfig.app.json b/tsconfig.app.json
index 491e093..80f52d1 100644
--- a/tsconfig.app.json
+++ b/tsconfig.app.json
@@ -3,6 +3,8 @@
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
+ "target": "ES2022",
+ "lib": ["ES2023", "DOM"],
"composite": true,
"noEmit": true,
"baseUrl": ".",