import BN from 'bn.js';
import { assert } from '../utils';
export const toDateTime = (value) => {
    if (typeof value === 'string' || isDateObject(value)) {
        const date = new Date(value);
        const timestamp = Math.floor(date.getTime() / 1000);
        return new BN(timestamp);
    }
    return new BN(value);
};
export const now = () => toDateTime(new Date(Date.now()));
export const toOptionDateTime = (value) => {
    return value === null ? null : toDateTime(value);
};
export const isDateTime = (value) => {
    return (value === null || value === void 0 ? void 0 : value.__opaque__) === 'DateTime';
};
export function assertDateTime(value) {
    assert(isDateTime(value), 'Expected DateTime type');
}
const isDateObject = (value) => {
    return Object.prototype.toString.call(value) === '[object Date]';
};
export const formatDateTime = (value, 
// @ts-ignore
locales = 'en-US', 
// @ts-ignore
options = {
    month: 'short',
    day: 'numeric',
    year: 'numeric',
    hour: 'numeric',
    minute: 'numeric',
}) => {
    const date = new Date(value.toNumber() * 1000);
    return date.toLocaleDateString(locales, options);
};
//# sourceMappingURL=DateTime.js.map