2023-06-14 11:39:00 -04:00
|
|
|
interface ITick {
|
|
|
|
id: number
|
|
|
|
track_id?: number
|
|
|
|
year?: number
|
|
|
|
month?: number
|
|
|
|
day?: number
|
|
|
|
hour?: number
|
|
|
|
minute?: number
|
|
|
|
second?: number
|
|
|
|
has_time_info?: number
|
|
|
|
}
|
|
|
|
|
|
|
|
class Tick implements ITick {
|
|
|
|
id: number
|
|
|
|
track_id?: number
|
|
|
|
year?: number
|
|
|
|
month?: number
|
|
|
|
day?: number
|
|
|
|
hour?: number
|
|
|
|
minute?: number
|
|
|
|
second?: number
|
|
|
|
has_time_info?: number
|
|
|
|
|
|
|
|
constructor(id: number,
|
|
|
|
track_id?: number,
|
|
|
|
year?: number,
|
|
|
|
month?: number,
|
|
|
|
day?: number,
|
|
|
|
hour?: number,
|
|
|
|
minute?: number,
|
|
|
|
second?: number,
|
|
|
|
has_time_info?: number,
|
|
|
|
) {
|
|
|
|
this.id = id
|
|
|
|
this.track_id = track_id
|
|
|
|
this.year = year
|
|
|
|
this.month = month
|
|
|
|
this.day = day
|
|
|
|
this.hour = hour
|
|
|
|
this.minute = minute
|
|
|
|
this.second = second
|
|
|
|
this.has_time_info = has_time_info
|
|
|
|
}
|
|
|
|
|
|
|
|
static fromJSON(tick: ITick): Tick {
|
|
|
|
return new Tick(
|
|
|
|
tick.id,
|
|
|
|
tick.track_id,
|
|
|
|
tick.year,
|
|
|
|
tick.month,
|
|
|
|
tick.day,
|
|
|
|
tick.hour,
|
|
|
|
tick.minute,
|
|
|
|
tick.second,
|
|
|
|
tick.has_time_info,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
date(): Date | null {
|
|
|
|
if (this.year && this.month && this.day && this.hour && this.minute && this.second) {
|
2023-06-20 08:40:35 -04:00
|
|
|
return new Date(this.year!, this.month!, this.day, this.hour, this.minute, this.second)
|
2023-06-14 11:39:00 -04:00
|
|
|
}
|
2023-06-20 08:40:35 -04:00
|
|
|
return null
|
2023-06-14 11:39:00 -04:00
|
|
|
}
|
|
|
|
}
|