Skip to main content Link Search Menu Expand Document (external link)

index overview

Added in v0.1.0


Table of contents


constructors

FixedClock

Signature

export declare function FixedClock(date: Date): Clock

Example

import * as C from 'clock-ts'

const date = new Date('2001-02-03')
const clock = C.FixedClock(date)
assert.deepStrictEqual(clock(), date)

Added in v0.1.0

SystemClock

Signature

export declare const SystemClock: Clock

Added in v0.1.0

model

Clock (type alias)

Signature

export type Clock = IO<Date>

Added in v0.1.0

ClockEnv (interface)

Signature

export interface ClockEnv {
  readonly clock: Clock
}

Added in v0.1.0

utils

now

Signature

export declare const now: RIO.ReaderIO<ClockEnv, Date>

Example

import * as C from 'clock-ts'
import { pipe } from 'fp-ts/function'

const date = new Date('2001-02-03')
const env = { clock: C.FixedClock(date) }
assert.deepStrictEqual(pipe(env, C.now)(), date)

Added in v0.1.0