We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encode timestamp into a number?
The text was updated successfully, but these errors were encountered:
My current algorithm:
export class TimeRange { public start: number; public end: number; constructor(start: number, end: number); constructor(start: [number, number], end: [number, number]); constructor(start: number | [number, number], end: number | [number, number]) { if (Array.isArray(start) && Array.isArray(end)) { this.start = start[0] * (60 * 24) + start[1]; this.end = end[0] * (60 * 24) + end[1]; } else if (typeof start === "number" && typeof end === "number") { this.start = start; this.end = end; } else { throw new TypeError("Invalid arguments"); } } public get code(): number { return this.start * 100_000 + this.end; } public in(range: TimeRange): boolean { return this.start >= range.start && this.end <= range.end; } }
Sorry, something went wrong.
JacobLinCool
No branches or pull requests
Encode timestamp into a number?
The text was updated successfully, but these errors were encountered: