@rschedule/rschedule
Version:
A typescript library for working with recurring dates and events.
46 lines • 1.82 kB
TypeScript
import { DateTime, IDateAdapter } from '../../date-time';
import { RuleOption } from '../rule-options';
import { IPipeRule, IPipeRunFn, PipeRule } from './interfaces';
export interface IFrequencyRuleOptions {
frequency: RuleOption.Frequency;
interval: RuleOption.Interval;
weekStart: RuleOption.WeekStart;
}
/**
* The `FrequencyPipe` is the first pipe in the chain of rule pipes. It is
* responsible for incrementing the date, as appropriate, while taking into
* account the `RRULE` frequency and interval.
*/
export declare class FrequencyPipe extends PipeRule<IFrequencyRuleOptions> implements IPipeRule<IFrequencyRuleOptions> {
private readonly intervalUnit;
private intervalStartDate;
private intervalEndDate;
run(args: IPipeRunFn): DateTime | null;
private normalizedStartDate;
private normalizedEndDate;
private incrementInterval;
private skipToIntervalOnOrAfter;
private dateIsWithinInterval;
}
/**
* Given the frequency (unit) and interval, this function finds
* how many jumps forward the first date needs in order to equal
* or exceed the second date.
*
* For example:
*
* 1. Unit is daily and interval is 1. The second date is 3 days
* after the first. This will return 3.
* 2. Unit is yearly and interval is 1. The second date is 3 days
* after the first. This will return 0.
* 3. Unit is yearly and interval is 3. The second date is 4 years
* after the first. This will return 6.
*/
export declare function intervalDifferenceBetweenDates({ first, second, unit, interval, weekStart, }: {
first: DateTime;
second: DateTime;
unit: IDateAdapter.TimeUnit | 'week';
interval: number;
weekStart: IDateAdapter.Weekday;
}): number;
//# sourceMappingURL=01-frequency.pipe.d.ts.map