50
*/
51
export function parseTimeToken(text: string, prefix: string): number | undefined {
52
>
const regex = new RegExp(`${prefix}:(\\d{4})(?:-(\\d{2})(?:-(\\d{2})(?:t(\\d{1,2})(?::(\\d{2})(?::(\\d{2}))?)?)?)?)?(?!\\w)`);
chatDebugEvents.ts
53
>
const m = regex.exec(text);
54
>
if (!m) {
55
return undefined;
56
}
57
58
const year = parseInt(m[1], 10);
59
>
const month = m[2] !== undefined ? parseInt(m[2], 10) - 1 : undefined;
chatDebugEvents.ts
60
>
const day = m[3] !== undefined ? parseInt(m[3], 10) : undefined;
61
>
const hour = m[4] !== undefined ? parseInt(m[4], 10) : undefined;
62
>
const minute = m[5] !== undefined ? parseInt(m[5], 10) : undefined;
63
>
const second = m[6] !== undefined ? parseInt(m[6], 10) : undefined;
64
>
65
>
if (prefix === 'before') {
66
if (second !== undefined) {
67
return new Date(year, month!, day!, hour!, minute!, second, 999).getTime();