Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4973.js (118.4 MB)
121 lines
3.8 KiB
TypeScript
121 lines
3.8 KiB
TypeScript
// Module ID: 5266
|
|
// Function ID: 5267
|
|
// Name: TimestampUtils
|
|
// Dependencies: [4470, 4380, 1091, 2]
|
|
// Exports: formatTimestampMention, parseTimestamp, unparseTimestamp
|
|
|
|
// Module 5266 (TimestampUtils)
|
|
import DurationsDefault from "Durations" /* 1091 */;
|
|
import _modDef4380 from "module_4380" /* 4380 */;
|
|
import DateUtils from "DateUtils" /* 4470 */;
|
|
import size from "module_2" /* 2 */;
|
|
|
|
const TIMESTAMP_FORMATS = {
|
|
t(date) {
|
|
return DateUtils.dateFormat(date, "LT");
|
|
},
|
|
T(date) {
|
|
return DateUtils.dateFormat(date, "LTS");
|
|
},
|
|
d(date) {
|
|
return DateUtils.dateFormat(date, "L");
|
|
},
|
|
D(date) {
|
|
return DateUtils.dateFormat(date, "LL");
|
|
},
|
|
f(date) {
|
|
return DateUtils.dateFormat(date, "LLL");
|
|
},
|
|
F(date) {
|
|
return DateUtils.dateFormat(date, "LLLL");
|
|
},
|
|
s(date) {
|
|
return DateUtils.dateFormat(date, "L LT");
|
|
},
|
|
S(date) {
|
|
return DateUtils.dateFormat(date, "L LTS");
|
|
},
|
|
R(toDate) {
|
|
const result = _modDef4380.relativeTimeThreshold("s");
|
|
const result1 = _modDef4380.relativeTimeThreshold("s", 60);
|
|
const result2 = _modDef4380.relativeTimeThreshold("ss");
|
|
const result3 = _modDef4380.relativeTimeThreshold("ss", -1);
|
|
const result4 = _modDef4380.relativeTimeThreshold("m");
|
|
const result5 = _modDef4380.relativeTimeThreshold("m", 60);
|
|
try {
|
|
const tmpResult = tmp(4380);
|
|
let fromNowResult = tmp(4380)(toDate.toDate()).fromNow();
|
|
const tmpResultResult = tmp(4380)(toDate.toDate());
|
|
const result6 = tmp(4380).relativeTimeThreshold("s", result);
|
|
const tmpResult5 = tmp(4380);
|
|
const result7 = tmp(4380).relativeTimeThreshold("ss", result2);
|
|
const tmpResult6 = tmp(4380);
|
|
const result8 = tmp(4380).relativeTimeThreshold("m", result4);
|
|
if (fromNowResult == null) {
|
|
const tmpResult8 = tmp(4380);
|
|
fromNowResult = tmp(4380)(toDate.toDate()).fromNow();
|
|
const tmpResult4Result = tmp(4380)(toDate.toDate());
|
|
}
|
|
return fromNowResult;
|
|
} catch (err) {
|
|
}
|
|
}
|
|
};
|
|
Object.setPrototypeOf(TIMESTAMP_FORMATS, null);
|
|
const keys = Object.keys(TIMESTAMP_FORMATS);
|
|
const regExp = new RegExp("^<t:(-?\\d{1,17})(?::(" + keys.join("|") + "))?>");
|
|
let result = size.fileFinishedImporting("modules/markup/TimestampUtils.tsx");
|
|
|
|
export { TIMESTAMP_FORMATS };
|
|
export const DEFAULT_TIMESTAMP_FORMAT = "f";
|
|
export const TIMESTAMP_REGEX = regExp;
|
|
export const formatTimestampMention = function formatTimestampMention(mention) {
|
|
({ timestamp, format } = mention);
|
|
const tmp = _modDef4380;
|
|
const tmpResult = tmp(Number(timestamp) * DurationsDefault.Millis.SECOND);
|
|
if (tmpResult.isValid()) {
|
|
let f;
|
|
if (null != format) {
|
|
f = obj[format];
|
|
}
|
|
if (null == f) {
|
|
f = obj.f;
|
|
}
|
|
obj = { timestamp, format, parsed: tmpResult, full: null, formatted: null };
|
|
obj.full = obj.F(tmpResult);
|
|
obj.formatted = f(tmpResult);
|
|
return obj;
|
|
} else {
|
|
return null;
|
|
}
|
|
const NumberResult = Number(timestamp);
|
|
};
|
|
export const parseTimestamp = function parseTimestamp(timestamp, format) {
|
|
const tmp = _modDef4380;
|
|
const tmpResult = tmp(Number(timestamp) * DurationsDefault.Millis.SECOND);
|
|
let tmp3 = null;
|
|
if (tmpResult.isValid()) {
|
|
let f;
|
|
if (null != format) {
|
|
f = obj[format];
|
|
}
|
|
if (null == f) {
|
|
f = obj.f;
|
|
}
|
|
obj = { timestamp, format, parsed: tmpResult, full: null, formatted: null };
|
|
obj.full = obj.F(tmpResult);
|
|
obj.formatted = f(tmpResult);
|
|
tmp3 = obj;
|
|
}
|
|
return tmp3;
|
|
};
|
|
export const unparseTimestamp = function unparseTimestamp(timestamp, format) {
|
|
if (null != format) {
|
|
const _HermesInternal2 = HermesInternal;
|
|
let combined = "<t:" + timestamp + ":" + format + ">";
|
|
} else {
|
|
const _HermesInternal = HermesInternal;
|
|
combined = "<t:" + timestamp + ">";
|
|
}
|
|
return combined;
|
|
};
|