Kit
Functions

isUnixTimestamp

isUnixTimestamp(putativeTimestamp): putativeTimestamp is UnixTimestamp

This is a type guard that accepts a bigint as input. It will both return true if the integer conforms to the UnixTimestamp type and will refine the type for use in your program.

Parameters

ParameterType
putativeTimestampbigint

Returns

putativeTimestamp is UnixTimestamp

Example

import { isUnixTimestamp } from '@solana/rpc-types';
 
if (isUnixTimestamp(timestamp)) {
    // At this point, `timestamp` has been refined to a
    // `UnixTimestamp` that can be used anywhere timestamps are expected.
    timestamp satisfies UnixTimestamp;
} else {
    setError(`${timestamp} is not a Unix timestamp`);
}

On this page