This commit is contained in:
@@ -28,6 +28,21 @@ export function defaultView() {
|
||||
return 'today' as const
|
||||
}
|
||||
|
||||
export function quickTaskFields(view: string, activeList: string, inboxList: string, now = new Date()) {
|
||||
if (view !== 'today') return { list_id: activeList }
|
||||
const parts = new Intl.DateTimeFormat('en-CA', {
|
||||
timeZone: 'Asia/Shanghai',
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
}).formatToParts(now)
|
||||
const value = (type: Intl.DateTimeFormatPartTypes) => parts.find((part) => part.type === type)?.value
|
||||
return {
|
||||
list_id: inboxList,
|
||||
due_at: `${value('year')}-${value('month')}-${value('day')}T12:00:00+08:00`,
|
||||
}
|
||||
}
|
||||
|
||||
export function isHabitComplete(kind: string | undefined, value: number | boolean | undefined, target = 1) {
|
||||
if (kind === 'numeric') return Number(value ?? 0) >= target
|
||||
return Boolean(value)
|
||||
|
||||
Reference in New Issue
Block a user