@nova-ui/bits
Version:
SolarWinds Nova Framework
88 lines (85 loc) • 3.45 kB
TypeScript
import moment, { Duration, Moment } from "moment/moment";
import { ITimeframe, ITimeFramePresetDictionary } from "../public-api";
import * as i0 from "@angular/core";
/**
* __Name : __
* Timeframe service
*
* __Usage :__
* Used to get time frames via time patterns or presets
*/
/**
* @ignore
*/
export declare class TimeframeService {
static cloneTimeFrame(timeFrame: ITimeframe): ITimeframe;
defaultPresets: ITimeFramePresetDictionary;
currentPresets: ITimeFramePresetDictionary;
constructor();
/**
*
* __Description:__ Get timeframe from patterns of start and end points in time
* @param startDatetimePattern
* @param endDatetimePattern
* @param baseDatetime
*/
getTimeframe(startDatetimePattern: any, endDatetimePattern: any, baseDatetime?: string): ITimeframe;
/**
* __Description:__ Get timeframe by preset id, using the list of pre-defined presets
*/
getTimeframeByPresetId(id: string | undefined, baseDatetime?: string): ITimeframe;
/**
* __Description:__ Updates start and end time of timeframe according to preset if selected
*
* @param timeFrame timeframe to be updated
* @param presets presets to look at. Defaults to service's currentPresets
* @param baseDatetime date that should be used for relative time calculations. Defaults to now.
* @returns updated clone of timeframe with startDatetime and endDatetime reconciled with selectedPresetId
*/
reconcileTimeframe: (timeFrame: ITimeframe, presets?: ITimeFramePresetDictionary, baseDatetime?: Moment) => ITimeframe;
/**
* __Description:__ Get the list of all default presets
*/
getDefaultPresets(): ITimeFramePresetDictionary;
/**
* __Description:__ Add custom presets to existing list of default presets
* @param presets
*/
extendCurrentPresets(presets: ITimeFramePresetDictionary): void;
/**
* __Description:__ Compare two timeframes, return false if they are not equal
*/
isEqual(firstTimeFrame: ITimeframe, secondTimeFrame: ITimeframe, units?: moment.unitOfTime.Base): boolean;
/**
* __Description:__ Compare two timeframe durations, return false if they are not equal
*/
isEqualDuration(firstTimeFrame: ITimeframe, secondTimeFrame: ITimeframe, units?: moment.unitOfTime.Base): boolean;
/**
* __Description:__
* Adds the specified duration to startDatetime and endDatetime and returns a new timeframe.
* Note: Input timeframe is not mutated.
*
* @param {ITimeframe} timeFrame The timeframe to shift
* @param {Duration} duration The duration of the timeframe shift
* @returns {ITimeframe} The shifted timeframe
*/
shiftTimeFrame(timeFrame: ITimeframe, duration: Duration): ITimeframe;
/**
* __Description:__
* Returns the difference between timeFrame's startDatetime and endDatetime as moment.Duration
*
* @param {ITimeframe} timeFrame
* @returns {Duration}
*/
getDuration(timeFrame: ITimeframe): Duration;
/**
* __Description:__
* Checks timeFrame "startDatetime" and "endDatetime" attributes for moment validity
*
* @param {ITimeframe} tf
* @returns {Boolean}
*/
areTimeFrameDatesValid(tf: ITimeframe): boolean;
static ɵfac: i0.ɵɵFactoryDeclaration<TimeframeService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<TimeframeService>;
}