UNPKG

chronos-ts

Version:

A comprehensive TypeScript library for date and time manipulation, inspired by Carbon PHP. Features immutable API, intervals, periods, timezones, and i18n support.

72 lines (71 loc) 3.47 kB
"use strict"; /** * Core type definitions for Chronos * @module types */ Object.defineProperty(exports, "__esModule", { value: true }); exports.MILLISECONDS_PER_YEAR = exports.MILLISECONDS_PER_MONTH = exports.AVERAGE_DAYS_PER_YEAR = exports.AVERAGE_DAYS_PER_MONTH = exports.MILLISECONDS_PER_WEEK = exports.MILLISECONDS_PER_DAY = exports.MILLISECONDS_PER_HOUR = exports.MILLISECONDS_PER_MINUTE = exports.DAYS_PER_LEAP_YEAR = exports.DAYS_PER_YEAR = exports.MONTHS_PER_YEAR = exports.DAYS_PER_WEEK = exports.HOURS_PER_DAY = exports.MINUTES_PER_HOUR = exports.SECONDS_PER_MINUTE = exports.MILLISECONDS_PER_SECOND = exports.PeriodBoundary = exports.Month = exports.DayOfWeek = void 0; // ============================================================================ // Day of Week Types // ============================================================================ /** * Days of the week (0 = Sunday, 6 = Saturday) */ var DayOfWeek; (function (DayOfWeek) { DayOfWeek[DayOfWeek["Sunday"] = 0] = "Sunday"; DayOfWeek[DayOfWeek["Monday"] = 1] = "Monday"; DayOfWeek[DayOfWeek["Tuesday"] = 2] = "Tuesday"; DayOfWeek[DayOfWeek["Wednesday"] = 3] = "Wednesday"; DayOfWeek[DayOfWeek["Thursday"] = 4] = "Thursday"; DayOfWeek[DayOfWeek["Friday"] = 5] = "Friday"; DayOfWeek[DayOfWeek["Saturday"] = 6] = "Saturday"; })(DayOfWeek || (exports.DayOfWeek = DayOfWeek = {})); /** * Months of the year (1 = January, 12 = December) */ var Month; (function (Month) { Month[Month["January"] = 1] = "January"; Month[Month["February"] = 2] = "February"; Month[Month["March"] = 3] = "March"; Month[Month["April"] = 4] = "April"; Month[Month["May"] = 5] = "May"; Month[Month["June"] = 6] = "June"; Month[Month["July"] = 7] = "July"; Month[Month["August"] = 8] = "August"; Month[Month["September"] = 9] = "September"; Month[Month["October"] = 10] = "October"; Month[Month["November"] = 11] = "November"; Month[Month["December"] = 12] = "December"; })(Month || (exports.Month = Month = {})); /** * Period boundary options */ var PeriodBoundary; (function (PeriodBoundary) { PeriodBoundary["Open"] = "open"; PeriodBoundary["Closed"] = "closed"; PeriodBoundary["OpenStart"] = "openStart"; PeriodBoundary["OpenEnd"] = "openEnd"; })(PeriodBoundary || (exports.PeriodBoundary = PeriodBoundary = {})); // ============================================================================ // Constants // ============================================================================ exports.MILLISECONDS_PER_SECOND = 1000; exports.SECONDS_PER_MINUTE = 60; exports.MINUTES_PER_HOUR = 60; exports.HOURS_PER_DAY = 24; exports.DAYS_PER_WEEK = 7; exports.MONTHS_PER_YEAR = 12; exports.DAYS_PER_YEAR = 365; exports.DAYS_PER_LEAP_YEAR = 366; exports.MILLISECONDS_PER_MINUTE = exports.MILLISECONDS_PER_SECOND * exports.SECONDS_PER_MINUTE; exports.MILLISECONDS_PER_HOUR = exports.MILLISECONDS_PER_MINUTE * exports.MINUTES_PER_HOUR; exports.MILLISECONDS_PER_DAY = exports.MILLISECONDS_PER_HOUR * exports.HOURS_PER_DAY; exports.MILLISECONDS_PER_WEEK = exports.MILLISECONDS_PER_DAY * exports.DAYS_PER_WEEK; // Average values for variable-length units exports.AVERAGE_DAYS_PER_MONTH = 30.436875; exports.AVERAGE_DAYS_PER_YEAR = 365.2425; exports.MILLISECONDS_PER_MONTH = exports.MILLISECONDS_PER_DAY * exports.AVERAGE_DAYS_PER_MONTH; exports.MILLISECONDS_PER_YEAR = exports.MILLISECONDS_PER_DAY * exports.AVERAGE_DAYS_PER_YEAR;