Skip to content

Instantly share code, notes, and snippets.

@philihp
Last active May 24, 2023 07:47
Show Gist options
  • Select an option

  • Save philihp/43a1b4e107a0e55163d774824a13547e to your computer and use it in GitHub Desktop.

Select an option

Save philihp/43a1b4e107a0e55163d774824a13547e to your computer and use it in GitHub Desktop.

Revisions

  1. philihp revised this gist May 24, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion dayOfWeek.test.ts
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    import { getDayOfWeek } from '../dayOfWeek'
    import { getDayOfWeek } from './dayOfWeek'
    import test from 'node:test'
    import assert from 'node:assert/strict'

  2. philihp created this gist May 24, 2023.
    27 changes: 27 additions & 0 deletions dayOfWeek.test.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    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'))
    })
    })
    6 changes: 6 additions & 0 deletions dayOfWeek.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    import { partial, pipe } from 'ramda'

    export const getDayOfWeek = pipe(
    partial(Date.UTC, [1984, 3]),
    Intl.DateTimeFormat(undefined, { weekday: 'long' }).format
    )