src/app/shared/utils/period-time.ts
Properties |
Methods |
|
Static getPeriod | ||||||||
getPeriod(periodName: PeriodTimeName)
|
||||||||
Defined in src/app/shared/utils/period-time.ts:11
|
||||||||
Parameters :
Returns :
Period
|
Readonly Static All |
All:
|
Type : PeriodTimeName
|
Default value : "All time"
|
Defined in src/app/shared/utils/period-time.ts:9
|
Readonly Static Day |
Day:
|
Type : PeriodTimeName
|
Default value : "Day"
|
Defined in src/app/shared/utils/period-time.ts:5
|
Readonly Static Month |
Month:
|
Type : PeriodTimeName
|
Default value : "Month"
|
Defined in src/app/shared/utils/period-time.ts:7
|
Readonly Static Week |
Week:
|
Type : PeriodTimeName
|
Default value : "Week"
|
Defined in src/app/shared/utils/period-time.ts:6
|
Readonly Static Year |
Year:
|
Type : PeriodTimeName
|
Default value : "Year"
|
Defined in src/app/shared/utils/period-time.ts:8
|
import {Period} from "../models/period";
export class PeriodTime {
static readonly Day: PeriodTimeName = "Day";
static readonly Week: PeriodTimeName = "Week";
static readonly Month: PeriodTimeName = "Month";
static readonly Year: PeriodTimeName = "Year";
static readonly All: PeriodTimeName = "All time";
static getPeriod(periodName: PeriodTimeName): Period {
let fromTime = new Date();
switch (periodName) {
case PeriodTime.Day:
break;
case PeriodTime.Week:
fromTime.setDate(fromTime.getDate() - 7);
break;
case PeriodTime.Month:
fromTime.setMonth(fromTime.getMonth() - 1);
break;
case PeriodTime.Year:
fromTime.setFullYear(fromTime.getFullYear() - 1);
break;
case PeriodTime.All:
fromTime.setTime(0);
break;
}
return new Period(fromTime.getTime(), new Date().getTime()).toStartAndEndOfDay()
}
}
export type PeriodTimeName = "Day" | "Week" | "Month" | "Year" | "All time"