diff --git a/src/components/column/ListCard.svelte b/src/components/column/ListCard.svelte
index a584580..d8dc1d9 100644
--- a/src/components/column/ListCard.svelte
+++ b/src/components/column/ListCard.svelte
@@ -4,7 +4,7 @@
import type { Card } from '../../datastore/models';
import { PRIORITY, LABEL_COLOR } from '../../types';
import type { TimeEntry } from '../../types';
- import { formatDate, formatForStopwatch, formatTime } from '../../util';
+ import { beforeDate, formatDate, formatForStopwatch, formatTime } from '../../util';
export let c: Card;
export let isFocused: boolean = false;
@@ -82,7 +82,13 @@
{/if}
{#if card.due}
-
+
diff --git a/src/util/index.ts b/src/util/index.ts
index 2853272..829ae59 100644
--- a/src/util/index.ts
+++ b/src/util/index.ts
@@ -1,7 +1,22 @@
import { customAlphabet } from 'nanoid';
-let d: Date = new Date();
-let currentYear: number = new Date().getFullYear();
+const d: Date = new Date();
+const day: number = d.getDate();
+const month: number = d.getMonth();
+const year: number = d.getFullYear();
+
+const beforeDate = (timestamp: number, when: string): boolean => {
+ let tmpDate = new Date();
+
+ if (when === 'today') {
+ return timestamp < tmpDate.getTime();
+ } else if (when === 'tomorrow') {
+ tmpDate.setDate(tmpDate.getDate() + 1);
+ return timestamp < tmpDate.getTime();
+ }
+
+ return false;
+}
const clickOutside = (node: Node, closeAction: Function): object => {
const handleClick = (event: Event) => {
@@ -42,11 +57,17 @@ const getTimestamps = (d: Date): object => {
const formatDate = (timestamp: number): string => {
d.setTime(timestamp);
- if (d.getFullYear() == currentYear) {
- return d.toLocaleString('en', { month: 'short', day: 'numeric' });
+ if (
+ d.getDate() === day &&
+ d.getMonth() === month &&
+ d.getFullYear() === year
+ ) {
+ return d.toLocaleString('default', { hour: 'numeric', minute: 'numeric' });
+ } else if (d.getFullYear() == year) {
+ return d.toLocaleString('default', { month: 'short', day: 'numeric' });
}
- return d.toLocaleString('en', { month: 'short', day: 'numeric', year: 'numeric' });
+ return d.toLocaleString('default', { year: 'numeric' });
}
const formatForStopwatch = (seconds: number): string => {
@@ -85,6 +106,7 @@ const formatTime = (seconds: number): string => {
const nanoid = customAlphabet('2346789ABCDEFGHJKLMNPQRTUVWXYZabcdefghijkmnpqrtwxyz', 10);
export {
+ beforeDate,
clickOutside,
getTimestamps,
formatDate,