Skip to main content

Timestamp

Represents a point in time.

Timestamp makes it easier for Serenity/JS to work with information related to time, like domain events.

Learn more

Hierarchy

  • TinyType
    • Timestamp

Index

Methods

staticfromJSON

staticfromTimestampInSeconds

staticfromTimestampInMilliseconds

  • fromTimestampInMilliseconds(v: number): Timestamp

externalequals

  • equals(another: TinyType): boolean
  • @desc

    Compares two tiny types by value

    @example
    <caption>Comparing simple types</caption> class Id extends TinyTypeOf<string>() {}

    const id = new Id(3cc0852d-fda7-4f61-874e-0cfadbd6182a);

    id.equals(id) === true

    @example

    Comparing complex types recursively

    class FirstName extends TinyTypeOf<string>() {}
    class LastName extends TinyTypeOf<string>() {}
    class Age extends TinyTypeOf<number>() {}

    class Person extends TinyType {
    constructor(public readonly firstName: FirstName,
    public readonly lastName: LastName,
    public readonly age: Age,
    ) {
    super();
    }
    }

    const p1 = new Person(new FirstName('John'), new LastName('Smith'), new Age(42)),
    p2 = new Person(new FirstName('John'), new LastName('Smith'), new Age(42));

    p1.equals(p2) === true

    Parameters

    • externalanother: TinyType

    Returns boolean

diff

plus

less

isBefore

isBeforeOrEqual

isAfter

isAfterOrEqual

toMilliseconds

  • toMilliseconds(): number
  • Returns number

toSeconds

  • toSeconds(): number
  • Returns number

toJSON

  • toJSON(): string
  • Returns string

toString

  • toString(): string
  • Returns string

Constructors

constructor

  • Parameters

    • value: Date = ...

    Returns Timestamp

Properties

publicreadonlyvalue

value: Date = ...