Files
pomoday-app/src/utils/helpers.ts
Paul Spenke 09b4af9a6e Refactor task management, UI interactions, and theme support
- Added task editing functionality with `EditForm` and integrated it with `TodoItemTouch`.
- Switched `dueDate` fields to `due_date` for consistency with API.
- Updated `useTasks` to handle dynamic task updates, deletions, and periodic refresh.
- Enhanced `useApi` with a dedicated delete method.
- Improved UI responsiveness and styling with multi-theme support in DaisyUI.
- Simplified modal handling for task interactions (`EditForm`, `CreateForm`).
- Improved `useSettings` with a `theme` field to support theme switching.
- Extended task commands for tagging, text, and due date updates.
- Optimized `parser` for extended edit command parsing.
- Updated helpers and actions to use `luxon` for date manipulations.
- Streamlined task and view logic for improved usability and extensibility.
2026-03-08 19:54:30 +01:00

30 lines
780 B
TypeScript

import type { Task } from '../types.ts'
import { DateTime } from 'luxon'
import Sherlock from 'sherlockjs'
export function parseDueDate(text: string): Task['due_date'] {
try {
const parsed = Sherlock.parse(text)
if (parsed && parsed.startDate) {
return DateTime.fromMillis(parsed.startDate.getTime()).toUTC().toString()
}
}
catch {}
const ts = Date.parse(text)
const millis = Number.isNaN(ts) ? null : ts
return millis ? DateTime.fromMillis(millis).toUTC().toString() : null
}
export function stopWorkLogging(t: Task) {
if (t.logs && t.logs.length) {
const lastLog = t.logs[t.logs.length - 1]
if (lastLog.start && !lastLog.end) {
lastLog.end = DateTime.now().toUTC().toString()
}
}
else {
t.logs = null
}
return t
}