API reference
tseries.offsets
Date offset classes for arithmetic on dates. All offsets have apply(date), rollforward(date) and rollback(date) methods.
| Name | Summary |
|---|---|
BusinessDay | A business-day offset. Skips Saturday and Sunday. |
MonthEnd | An offset corresponding to the last business day of the month. |
MonthBegin | An offset corresponding to the first calendar day of the month. |
YearEnd | An offset for the last day of the year. |
YearBegin | An offset for the first day of the year. |
QuarterEnd | DateOffset increments between Quarter end dates. |
QuarterBegin | DateOffset increments between Quarter start dates. |
Week | A week offset. |
Day | A calendar day offset. |
Hour | An hour offset. |
Minute | A minute offset. |
Second | A second offset. |
BusinessHour | DateOffset subclass representing possibly n business hours. Default business hou |
BusinessDay
#new BusinessDay(n?)
A business-day offset. Skips Saturday and Sunday.
Parameters
nnumber- Number of business days. Default 1.
Returns
BusinessDay
Example
import { BusinessDay } from 'pandas-ts';
const bd = new BusinessDay(1);
bd.apply(new Date('2024-01-05')).toDateString(); // Friday -> Monday: 'Mon Jan 08 2024'MonthEnd
#new MonthEnd(n?)
An offset corresponding to the last business day of the month.
Returns
MonthEnd
Example
import { MonthEnd } from 'pandas-ts';
new MonthEnd(1).apply(new Date('2024-01-15')).getDate(); // => 31MonthBegin
#new MonthBegin(n?)
An offset corresponding to the first calendar day of the month.
Returns
MonthBegin
Example
new MonthBegin(1).apply(new Date('2024-01-15')).getDate(); // => 1YearEnd
#new YearEnd(n?, month?)
An offset for the last day of the year.
Returns
YearEnd
Example
new YearEnd(1).apply(new Date('2024-06-01')).toISOString().slice(0,10); // => '2024-12-31'YearBegin
#new YearBegin(n?)
An offset for the first day of the year.
Returns
YearBegin
Example
new YearBegin(1).apply(new Date('2024-06-01')).toISOString().slice(0,10); // => '2025-01-01'QuarterEnd
#new QuarterEnd(n?, startingMonth?)
DateOffset increments between Quarter end dates.
Returns
QuarterEnd
Example
new QuarterEnd(1).apply(new Date('2024-01-15')).toISOString().slice(0,10); // => '2024-03-31'QuarterBegin
#new QuarterBegin(n?, startingMonth?)
DateOffset increments between Quarter start dates.
Returns
QuarterBegin
Example
new QuarterBegin(1).apply(new Date('2024-02-15')).toISOString().slice(0,10); // => '2024-04-01'Week
#new Week(n?, weekday?)
A week offset.
Returns
Week
Example
new Week(2).apply(new Date('2024-01-01')).getDate(); // => 15Day
#new Day(n?)
A calendar day offset.
Returns
Day
Example
new Day(7).apply(new Date('2024-01-01')).getDate(); // => 8Hour
#new Hour(n?)
An hour offset.
Returns
Hour
Example
new Hour(6).apply(new Date('2024-01-01T00:00:00')).getHours(); // => 6Minute
#new Minute(n?)
A minute offset.
Returns
Minute
Example
new Minute(30).apply(new Date('2024-01-01T10:00:00')).getMinutes(); // => 30Second
#new Second(n?)
A second offset.
Returns
Second
Example
new Second(45).apply(new Date('2024-01-01T10:00:00')).getSeconds(); // => 45BusinessHour
#new BusinessHour(n?, start?, end?)
DateOffset subclass representing possibly n business hours. Default business hours: 09:00–17:00.
Returns
BusinessHour
Example
import { BusinessHour } from 'pandas-ts';
// Advancing from end of business hours rolls to next morning
const bh = new BusinessHour(1);
bh.rollforward(new Date('2024-01-05T18:00:00')).getHours(); // => 9