UNPKG

@georgevie/period-sequence

Version:

High-performance TypeScript library for time period manipulation with immutable design and enterprise-grade performance

95 lines 4.11 kB
/** * Named constructors for Period creation optimized for date-only operations * All constructors work with day-level precision and normalize to midnight UTC */ import { Period } from '../core/Period'; import { Bounds } from '../core/types'; import { DurationInterval } from '../duration/DurationInterval'; export declare namespace PeriodConstructors { /** * Create period from start and end dates (most common constructor) * Dates are automatically normalized to midnight UTC for date-only operations */ function fromDates(start: Date, end: Date, bounds?: Bounds): Period; /** * Create period from month (optimized for date-only operations) * Returns period covering the entire month at day-level precision */ function fromMonth(year: number, month: number, bounds?: Bounds): Period; /** * Create period from year (optimized for date-only operations) * Returns period covering the entire year at day-level precision */ function fromYear(year: number, bounds?: Bounds): Period; /** * Create period from a single day (optimized for date-only operations) * Returns a 1-day period for the specified date */ function fromDay(date: Date | string, bounds?: Bounds): Period; /** * Create period starting after a specific date (date-only operations) * Duration is applied at day-level precision, minimum 1 day */ function after(start: Date | string, duration: DurationInterval, bounds?: Bounds): Period; /** * Create period ending before a specific date (date-only operations) * Duration is applied at day-level precision, minimum 1 day */ function before(end: Date | string, duration: DurationInterval, bounds?: Bounds): Period; /** * Create period centered around a specific date (date-only operations) * Duration is split evenly around the center date, minimum 1 day each side */ function around(center: Date | string, duration: DurationInterval, bounds?: Bounds): Period; /** * Create period from ISO 8601 duration string starting at date * Combines parsing and construction for efficiency */ function fromISO8601(start: Date | string, isoDuration: string, bounds?: Bounds): Period; /** * Create period from ISO week (yyyy-Www format) * Optimized with direct UTC calculations */ function fromWeek(year: number, week: number, bounds?: Bounds): Period; /** * Create period from quarter (1-4) * Optimized with direct UTC calculations */ function fromQuarter(year: number, quarter: number, bounds?: Bounds): Period; /** * Create period from millisecond timestamps (date-only operations) * Timestamps are normalized to midnight UTC for consistent behavior */ function fromTimestamps(startMs: number, endMs: number, bounds?: Bounds): Period; /** * Create period representing today (current date in local timezone) * Returns a 1-day period for today at date-only precision */ function today(bounds?: Bounds): Period; /** * Create period representing this week (Monday to Sunday) * Uses ISO week calculation with date-only precision */ function thisWeek(bounds?: Bounds): Period; /** * Create period representing this month * Uses current date's month */ function thisMonth(bounds?: Bounds): Period; /** * Create period representing this year * Uses current date's year */ function thisYear(bounds?: Bounds): Period; /** * Create period starting from today with specified duration (date-only operations) * Uses current date as starting point, duration rounded up to whole days */ function fromToday(duration: DurationInterval, bounds?: Bounds): Period; /** * Create period with specified duration starting from given time * Alias for 'after' with clearer naming */ function fromDuration(start: Date | string | number, duration: DurationInterval, bounds?: Bounds): Period; } //# sourceMappingURL=PeriodConstructors.d.ts.map