Skip to content

Instantly share code, notes, and snippets.

@philihp
Last active May 24, 2023 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philihp/43a1b4e107a0e55163d774824a13547e to your computer and use it in GitHub Desktop.
Save philihp/43a1b4e107a0e55163d774824a13547e to your computer and use it in GitHub Desktop.
Day of Week
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'))
})
})
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