src/app/shared/utils/date-picker.type.ts
Properties |
Methods |
|
constructor(year: number, month: number, day: number, hour: number, minute: number, second: number)
|
Defined in src/app/shared/utils/date-picker.type.ts:1
|
Static fromJson | ||||||||
fromJson(date: )
|
||||||||
Defined in src/app/shared/utils/date-picker.type.ts:44
|
||||||||
Parameters :
Returns :
DatePicker
|
Static fromNumber | ||||||||
fromNumber(date: number)
|
||||||||
Defined in src/app/shared/utils/date-picker.type.ts:39
|
||||||||
Parameters :
Returns :
DatePicker
|
getFromTime |
getFromTime()
|
Defined in src/app/shared/utils/date-picker.type.ts:21
|
Returns :
number
|
getTime |
getTime()
|
Defined in src/app/shared/utils/date-picker.type.ts:10
|
Returns :
number
|
getToTime |
getToTime()
|
Defined in src/app/shared/utils/date-picker.type.ts:30
|
Returns :
number
|
Public day |
day:
|
Type : number
|
Defined in src/app/shared/utils/date-picker.type.ts:4
|
Public hour |
hour:
|
Type : number
|
Defined in src/app/shared/utils/date-picker.type.ts:5
|
Public minute |
minute:
|
Type : number
|
Defined in src/app/shared/utils/date-picker.type.ts:6
|
Public month |
month:
|
Type : number
|
Defined in src/app/shared/utils/date-picker.type.ts:3
|
Public second |
second:
|
Type : number
|
Default value : 0
|
Defined in src/app/shared/utils/date-picker.type.ts:7
|
Public year |
year:
|
Type : number
|
Defined in src/app/shared/utils/date-picker.type.ts:2
|
export class DatePicker {
constructor(public year: number,
public month: number,
public day: number,
public hour: number,
public minute: number,
public second: number = 0) {
}
getTime(): number {
let d = new Date();
d.setFullYear(this.year);
d.setMonth(this.month - 1);
d.setDate(this.day);
d.setHours(this.hour);
d.setMinutes(this.minute);
d.setSeconds(this.second);
return d.getTime();
}
getFromTime(): number {
let d = new Date();
d.setFullYear(this.year);
d.setMonth(this.month - 1);
d.setDate(this.day);
d.setHours(0, 0, 0, 0);
return d.getTime();
}
getToTime(): number {
let d = new Date();
d.setFullYear(this.year);
d.setMonth(this.month - 1);
d.setDate(this.day);
d.setHours(23, 59, 59, 999);
return d.getTime();
}
static fromNumber(date: number) {
const d = new Date(date);
return new DatePicker(d.getFullYear(), d.getMonth() + 1, d.getDate(), d.getHours(), d.getMinutes());
}
static fromJson(date) {
return new DatePicker(date.year, date.month, date.day, date.hour, date.minute)
}
}