@kelvininc/ui-components
Version:
Kelvin UI Components
192 lines (191 loc) • 4.71 kB
JavaScript
import { ERelativeTimeRangeKey, EUnitReference } from "./relative-time.types";
/**
* Configuration mapping for all relative time range keys.
*
* @remarks
* Defines how each `ERelativeTimeRangeKey` should be calculated:
* - Simple offsets add/subtract units from current time
* - Unit reference offsets align to start/end of time units
*
* @see {RelativeTimeOffsetConfig}
* @see {getRelativeTimeCalculation}
*/
export const RELATIVE_TIME_OFFSETS = {
[]: {
offset: -5,
unit: 'minutes'
},
[]: {
offset: -10,
unit: 'minutes'
},
[]: {
offset: -15,
unit: 'minutes'
},
[]: {
offset: -30,
unit: 'minutes'
},
[]: {
offset: -1,
unit: 'hours'
},
[]: {
offset: -3,
unit: 'hours'
},
[]: {
offset: -6,
unit: 'hours'
},
[]: {
offset: -12,
unit: 'hours'
},
[]: {
offset: -24,
unit: 'hours'
},
[]: {
offset: -48,
unit: 'hours'
},
[]: {
offset: -72,
unit: 'hours'
},
[]: {
offset: -3,
unit: 'days'
},
[]: {
offset: -7,
unit: 'days'
},
[]: {
offset: -14,
unit: 'days'
},
[]: {
offset: -30,
unit: 'days'
},
[]: {
offset: -90,
unit: 'days'
},
[]: {
offset: -1,
unit: 'months'
},
[]: {
offset: -6,
unit: 'months'
},
[]: {
offset: -1,
unit: 'years'
},
[]: {
offset: -2,
unit: 'years'
},
[]: {
offset: -5,
unit: 'years'
},
[]: {
offset: -365,
unit: 'days'
},
// Special - Unit-based references
[]: {
offset: 0,
unit: 'day',
unitReference: EUnitReference.StartOfUnit
},
[]: {
offset: -1,
unit: 'day',
unitReference: EUnitReference.StartOfUnit
},
[]: {
offset: -1,
unit: 'day',
unitReference: EUnitReference.EndOfUnit
},
// "So far" ranges (from start of unit to now)
[]: {
offset: 0,
unit: 'week',
unitReference: EUnitReference.StartOfUnit
},
[]: {
offset: 0,
unit: 'month',
unitReference: EUnitReference.StartOfUnit
},
[]: {
offset: 0,
unit: 'quarter',
unitReference: EUnitReference.StartOfUnit
},
[]: {
offset: 0,
unit: 'year',
unitReference: EUnitReference.StartOfUnit
},
[]: {
offset: 5,
unit: 'minutes'
},
[]: {
offset: 10,
unit: 'minutes'
},
[]: {
offset: 15,
unit: 'minutes'
},
[]: {
offset: 30,
unit: 'minutes'
},
[]: {
offset: 1,
unit: 'hours'
},
[]: {
offset: 6,
unit: 'hours'
},
[]: {
offset: 12,
unit: 'hours'
},
[]: {
offset: 24,
unit: 'hours'
},
[]: {
offset: 48,
unit: 'hours'
},
[]: {
offset: 72,
unit: 'hours'
},
[]: {
offset: 7,
unit: 'days'
},
[]: {
offset: 2,
unit: 'weeks'
},
[]: {
offset: 1,
unit: 'months'
}
};