Last active
May 24, 2023 07:47
-
-
Save philihp/43a1b4e107a0e55163d774824a13547e to your computer and use it in GitHub Desktop.
Day of Week
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getDayOfWeek } from './dayOfWeek' | |
import test from 'node:test' | |
import assert from 'node:assert/strict' | |
describe('dayOfWeek', () => { | |
test('returns Sunday', () => { | |
assert.strictEqual(getDayOfWeek(1), ('Sunday')) | |
}) | |
test('returns Monday', () => { | |
assert.strictEqual(getDayOfWeek(2), ('Monday')) | |
}) | |
test('returns Tuesday', () => { | |
assert.strictEqual(getDayOfWeek(3), ('Tuesday')) | |
}) | |
test('returns Wednesday', () => { | |
assert.strictEqual(getDayOfWeek(4), ('Wednesday')) | |
}) | |
test('returns Thursday', () => { | |
assert.strictEqual(getDayOfWeek(5), ('Thursday')) | |
}) | |
test('returns Friday', () => { | |
assert.strictEqual(getDayOfWeek(6), ('Friday')) | |
}) | |
test('returns Saturday', () => { | |
assert.strictEqual(getDayOfWeek(7), ('Saturday')) | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { partial, pipe } from 'ramda' | |
export const getDayOfWeek = pipe( | |
partial(Date.UTC, [1984, 3]), | |
Intl.DateTimeFormat(undefined, { weekday: 'long' }).format | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment