Skip to content

Commit

Permalink
Add a weekday to the date selector
Browse files Browse the repository at this point in the history
  • Loading branch information
Dlurak committed Aug 27, 2024
1 parent daf24de commit 33f1792
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/input/date/DateSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

<span>
{#if date}
{stringify(date)}
{stringify(date, { weekday: 'short' })}
{:else}
<Store store={i('calendar.select')} />
{/if}
Expand Down
5 changes: 4 additions & 1 deletion src/lib/utils/dates/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ export const currentCustomDate = () => normalToCustomDate(new Date());
interface StringifyProps {
includeTime?: boolean;
includeDate?: boolean;
weekday?: 'short' | 'long' | 'narrow';
}

export const stringify = (d: CustomDate, props: StringifyProps = {}) => {
const includeTime = props.includeTime ?? false;
const includeDate = props.includeDate ?? true;
const weekday = props.weekday ?? null;

const timeOptions: Intl.DateTimeFormatOptions = includeTime
? {
Expand All @@ -66,7 +68,8 @@ export const stringify = (d: CustomDate, props: StringifyProps = {}) => {
? {
day: '2-digit',
month: '2-digit',
year: '2-digit'
year: '2-digit',
...(weekday ? { weekday } : null)
}
: {};

Expand Down

0 comments on commit 33f1792

Please sign in to comment.