# BlockTimestamp

Creates a block timestamp object

Rarely used, typically in blockchain block headers

# Constructors

  • constructor(
      public slot: u32 = 0
    )
    
    slot - Blocks since epoch

Example:

  import { BlockTimestamp } from 'proton-tsc'

  const bt = new BlockTimestamp(5)
  // tp.slot == 5
  • static fromTimePoint(t: TimePoint): BlockTimestamp
    

    Creates a BlockTimestamp object from a precise TimePoint

  • static fromTimePointSec(t: TimePointSec): BlockTimestamp
    

    Creates a BlockTimestamp object from a precise TimePointSec

# Static Fields

  • static blockIntervalMs: i32 = 500;
    

    Represents interval between each block

  • static blockTimestampEpoch: i64 = 946684800000;
    

    Start of epoch

# Static Methods

  • static function maximum(): BlockTimestamp
    

    Returns block timestamp of 0xffff (65535)

  • static function min(): BlockTimestamp
    

    Returns block timestamp of 0

# Instance Methods

  • function next(): BlockTimestamp
    

    Returns a new BlockTimestamp with slot incremented by 1

  • function toTimePoint(): TimePoint
    

    Convert block timestamp to a TimePoint object

  • function setTimePoint(t: TimePoint): void
    

    Sets the slot field using a time point

  • function setTimePointSec(t: TimePointSec): void
    

    Sets the slot field using a time point sec

  • function toString(): string
    

    Returns string representation of number of slots since epoch

# Static Equality methods

  • static function eq(a: BlockTimestamp, b: BlockTimestamp): bool
    

    Checks that the slots of the two block timestamps are equal

  • static function neq(a: BlockTimestamp, b: BlockTimestamp): bool
    

    Checks that the slots of the two block timestamps are not equal

  • static function lt(a: BlockTimestamp, b: BlockTimestamp): bool
    

    Checks that the slot of a is less than b

  • static function lte(a: BlockTimestamp, b: BlockTimestamp): bool
    

    Checks that the slot of a is less than or equal to b

  • static function gt(a: BlockTimestamp, b: BlockTimestamp): bool
    

    Checks that the slot of a is greater than b

  • static function gte(a: BlockTimestamp, b: BlockTimestamp): bool
    

    Checks that the slot of a is greater than or equal to b