Files
2026-07-28 01:06:53 +03:00

421 lines
19 KiB
TypeScript

/* Metro module 3826; source: utils/DateUtils.tsx; dependencies: [1949, 3, 3827, 3829, 1314, 3843, 1244, 694, 3845, 3738, 2] */
import Logger from '../modules/debug/Logger.tsx'; /* Metro dependency 3 */
import Dispatcher from '../Dispatcher.tsx'; /* Metro dependency 694 */
import LocaleStore from '../modules/user_settings/LocaleStore.tsx'; /* Metro dependency 1949 */
import Module03738 from '../by-id/module-03738.js'; /* Metro dependency 3738 */
import OnTimezoneChangeAndroid from '../modules/date/onTimezoneChange.android.tsx'; /* Metro dependency 3827 */
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as IndexNativeModule from '../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as UserSettingsModule from '../modules/user_settings/UserSettings.tsx'; /* Metro dependency 3829 */
function _fun31072(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#31072, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:6, offset: 0x00ff2798, size: 577 bytes, params: 8, frame: 27
const env0_0 = require;
const closure = function() {
var Object = global.Object;
};
const syncHourCycleToIntlConfig2 = syncHourCycleToIntlConfig;
const differenceInCalendarDays_310762 = differenceInCalendarDays_31076;
const dateFormat2 = dateFormat;
const dateStringToMoment2 = dateStringToMoment;
const toMoment = function(a0) {
var r0;
var value = a0;
if (importDefault(dependencyMap[9]).isMoment(value)) {
r0 = value;
} else {
value = importDefault(dependencyMap[9])(value);
r0 = value;
}
return r0;
};
const toDate_31080 = function(a0) {
var r0;
var value = a0;
if (importDefault(dependencyMap[9]).isMoment(value)) {
value = value.toDate();
r0 = value;
} else {
r0 = value;
}
return r0;
};
const closure6 = function() {
var Date = global.Date;
var value2 = new Date();
value2 = value2.toLocaleString('en-US', {timeZone: 'America/New_York'});
Date = global.Date;
var value3 = Object.create(Date.prototype, {constructor: {value: Date}});
value2 = new Date(value2);
return value2 instanceof Object ? value2 : value3;
};
let Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const value4 = new (Logger)('DateUtils');
Object = global.Object;
LocaleStore.addChangeListener(closure);
(OnTimezoneChangeAndroid)(closure);
(Dispatcher).subscribe('USER_SETTINGS_PROTO_UPDATE',
syncHourCycleToIntlConfig2);
(Dispatcher).subscribe('CONNECTION_OPEN', syncHourCycleToIntlConfig2);
object = [{'key': 'days', 'millisecondsInUnit': 86400000}, {'key': 'hours', 'millisecondsInUnit': 3600000},
{'key': 'minutes', 'millisecondsInUnit': 60000}, {'key': 'seconds', 'millisecondsInUnit': 1000}];
(FileImportTrackerModule).fileFinishedImporting('utils/DateUtils.tsx');
exports.differenceInCalendarDays = differenceInCalendarDays_310762;
exports.differenceInDays = differenceInDays_31082;
exports.isSameHourMoment = function(a0, a1) {
var r0;
var value = a0.toDate();
var value2 = a1.toDate();
var Math = global.Math;
var value5 = Math.abs(Number(value) - Number(value2)) <= 3600000;
if (value5) {
value = value.getHours();
value = value === value2.getHours();
r0 = value;
} else {
r0 = value5;
}
return r0;
};
exports.isSameDay = isSameDay_31084;
exports.isWithinInterval = function(a0, a1, a2) {
var Math = global.Math;
var value = a0.valueOf();
value = Math.abs(value - a1.valueOf());
return value < a2;
};
exports.dateFormat = dateFormat2;
exports.calendarFormat = calendarFormat_31086;
exports.calendarFormatCompact = calendarFormatCompact;
exports.dateStringToMoment = dateStringToMoment2;
exports.accessibilityLabelCalendarFormat = accessibilityLabelCalendarFormat;
exports.diffAsUnits = diffAsUnits;
exports.unitsAsStrings = unitsAsStrings;
exports.getESTDate = closure6;
exports.getMonthlyProgressPercentage = getMonthlyProgressPercentage;
exports.getDaysRemainingInMonth = getDaysRemainingInMonth;
exports.formatDateForDatetimeLocal = formatDateForDatetimeLocal;
function syncHourCycleToIntlConfig() { // fn#31074, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:212, offset: 0x00ff29f8, size: 317 bytes, params: 1, frame: 22
var r8;
var r6;
var r12;
var moduleValue;
var supportsSystemDateFormatter;
var value4;
var property;
var value7;
var value8;
var H12;
var H23;
var value9;
let TimestampHourCycle = (UserSettingsModule).TimestampHourCycle;
const setting = TimestampHourCycle.getSetting();
TimestampHourCycle = (require(1314) /* metro dependency 1314: preloaded_user_settings */).TimestampHourCycle;
const AUTO = TimestampHourCycle.AUTO;
const value3 = setting !== AUTO;
reducibleJoin2: while (true) {
if (value3) {
moduleValue = require(3843) /* metro dependency 3843: SystemDateFormatterNative */;
supportsSystemDateFormatter = moduleValue.supportsSystemDateFormatter;
value4 = Reflect.apply(supportsSystemDateFormatter, moduleValue, []);
r8 = value4;
break reducibleJoin2;
}
r8 = value3;
break reducibleJoin2;
}
const Object = global.Object;
const value5 = Object.values((IndexNativeModule).intl.formatConfig.time);
let length = value5.length;
const value6 = 0;
if (value6 < length) {
r6 = value6;
reducibleLoop3: while (true) {
property = value5[r6];
value7 = property != null;
reducibleJoin5: while (true) {
if (value7) {
value8 = 'hour' in property;
r12 = value8;
break reducibleJoin5;
}
r12 = value7;
break reducibleJoin5;
}
reducibleJoin13: while (true) {
if (r12) {
if (r8) {
TimestampHourCycle = (require(1314) /* metro dependency 1314: preloaded_user_settings */).TimestampHourCycle;
H12 = TimestampHourCycle.H12;
if (setting === H12) {
property.hourCycle = 'h12';
break reducibleJoin13;
}
}
if (r8) {
TimestampHourCycle = (require(1314) /* metro dependency 1314: preloaded_user_settings */).TimestampHourCycle;
H23 = TimestampHourCycle.H23;
if (setting === H23) {
property.hourCycle = 'h23';
break reducibleJoin13;
}
}
delete property.hourCycle;
break reducibleJoin13;
}
break reducibleJoin13;
}
value9 = typeof r6 === 'bigint' ? r6 + 1n : +r6 + 1;
length = value5.length;
if (value9 < length) {
r6 = value9;
continue reducibleLoop3;
}
break reducibleLoop3;
}
}
}
function startOfDay_31075(a0) { // fn#31075, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:616, offset: 0x00ff2b35, size: 224 bytes, params: 2, frame: 15
var r4;
var binding;
var date;
const value = a0;
const value2 = a1;
const r1 = !(value2 !== undefined) || value2;
const value4 = typeof value;
let r2 = value4 === 'string' || value4 === 'number';
r2 = !r2 ? value instanceof global.Date : r2;
if (r2) {
r4 = value;
} else {
binding = env0_3;
binding.error('Invalid date given to startOfDay', {d: value});
r4 = new global.Date();
}
const Date = global.Date;
const time = new Date().getTime();
if (r1) {
r4 = time;
} else {
date = date.getTimezoneOffset();
date = time - 60000 * date;
r4 = date;
}
const Math = global.Math;
return Math.floor(r4 / env0_4) * env0_4;
}
function differenceInCalendarDays_31076(a0, a1) { // fn#31076, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:865, offset: 0x00ff2c15, size: 62 bytes, params: 3, frame: 17
const Math = global.Math;
const floor = Math.floor;
const startOfDay_31075Binding = startOfDay_31075;
return Reflect.apply(floor, Math, [(startOfDay_31075Binding(a0, false) - startOfDay_31075Binding(a1,
false)) / env0_4]);
}
function dateFormat(a0, a1, a2) { // fn#31077, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:961, offset: 0x00ff2c53, size: 179 bytes, params: 4, frame: 22
var r1;
var binding;
var value5;
let value = a2;
value = '' + toMoment(a0).locale() + ':' + a1 + ':' + (value ?? (require(3829) /* metro dependency 3829: UserSettings */).TimestampHourCycle.getSetting());
const property = env0_5[value];
if (property != null) {
r1 = property;
} else {
binding = env0_5;
value5 = (importDefault(3845) /* metro dependency 3845: makeDateFormatter */)(a1);
binding[value] = value5;
r1 = value5;
}
return r1(toDate_31080(a0));
}
function dateStringToMoment(a0) { // fn#31078, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:1136, offset: 0x00ff2d06, size: 83 bytes, params: 2, frame: 12
if (a0.length >= 200) {
throw new global.Error('Date string exceeds maximum length');
}
return (Module03738)(a0);
}
function differenceInDays_31082(a0, a1) { // fn#31082, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:1972, offset: 0x00ff2e2c, size: 43 bytes, params: 3, frame: 10
let getTime = a0.getTime;
let value = Reflect.apply(getTime, a0, []);
getTime = a1.getTime;
value -= Reflect.apply(getTime, a1, []);
return value / env0_4;
}
function isSameDay_31084(a0, a1) { // fn#31084, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:2189, offset: 0x00ff2eb5, size: 75 bytes, params: 3, frame: 14
var r0;
const Math = global.Math;
const abs = Math.abs;
let value = Number(a0);
value = Reflect.apply(abs, Math, [value - Number(a1)]);
value = value <= env0_4;
if (value) {
value = a0.getDate();
value = value === a1.getDate();
r0 = value;
} else {
r0 = value;
}
return r0;
}
function calendarFormat_31086(a0) { // fn#31086, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:2404, offset: 0x00ff2f38, size: 223 bytes, params: 2, frame: 20
var value9;
const value = a1;
const r1 = value !== undefined ? value : false;
const value2 = (Module03738).localeData();
const value3 = (Module03738)();
const value5 = differenceInCalendarDays_31076(toDate_31080(a0), value3.toDate());
if (value5 < -1) {
return dateFormat(a0, 'L LT', a2);
}
if (value5 < 0) {
return dateFormat(a0, value2.calendar('lastDay', toMoment(a0), value3), a2);
}
if (value5 < 1) {
value9 = 'sameDay';
if (r1) {
return dateFormat(a0, 'LT', a2);
}
return dateFormat(a0, value2.calendar(value9, toMoment(a0), value3), a2);
}
return dateFormat(a0, value2.calendar(value5 < 2 ? 'nextDay' : 'sameElse', toMoment(a0), value3), a2);
}
function calendarFormatCompact(a0, a1) { // fn#31087, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:2753, offset: 0x00ff3017, size: 170 bytes, params: 3, frame: 20
var r0;
var r1;
var calendar;
var value;
const value2 = (Module03738).localeData();
const value3 = (Module03738)();
const value5 = differenceInCalendarDays_31076(toDate_31080(a0), value3.toDate());
const dateFormatBinding = dateFormat;
if (value5 === 0) {
r1 = 'LT';
} else {
if (value5 === -1) {
calendar = value2.calendar;
value = toMoment(a0);
value = Reflect.apply(calendar, value2, ['lastDay', value, value3]);
r0 = value;
} else {
r0 = value5 > -7 ? 'dddd' : 'L';
}
r1 = r0;
}
return dateFormatBinding(a0, r1, a1);
}
function accessibilityLabelCalendarFormat(a0) { // fn#31088, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:3048, offset: 0x00ff30c1, size: 218 bytes, params: 2, frame: 23
var r0;
var calendar;
var value;
const value2 = (importDefault(3738) /* metro dependency 3738 */).localeData();
const Date = global.Date;
const date = new Date();
const value5 = differenceInCalendarDays_31076(a0, date);
const dateFormatBinding = dateFormat;
const value6 = 'sameElse';
const r7 = value5 < -1 ? value6 : value5 < 0 ? 'lastDay' : value5 < 1 ? 'sameDay' : value5 < 2 ? 'nextDay' : value6;
if (value6 === r7) {
r0 = 'LLL';
} else {
calendar = value2.calendar;
value = (importDefault(3738) /* metro dependency 3738 */)(a0);
value = Reflect.apply(calendar, value2, [r7, value, (importDefault(3738) /* metro dependency 3738 */)(date)]);
r0 = value;
}
return dateFormatBinding(a0, r0);
}
function diffAsUnits(a0, a1) { // fn#31089, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:3332, offset: 0x00ff319b, size: 163 bytes, params: 3, frame: 16
var Number;
let value = a2;
const r2 = value !== undefined ? value : false;
var env0_1;
const object = {'days': 0, 'hours': 0, 'minutes': 0};
object.seconds = r2 ? 1 : 0;
if (!(a0 > a1)) {
if (r2) {
Number = global.Number;
value = Number(a0);
value += 1200;
Number = global.Number;
if (value > Number(a1)) {
return object;
}
Number = global.Number;
value = Number(a1);
Number = global.Number;
env0_1 = value - Number(a0);
env0_6.forEach(_fun31090);
return object;
}
Number = global.Number;
value = Number(a1);
Number = global.Number;
env0_1 = value - Number(a0);
env0_6.forEach(_fun31090);
}
return object;
function _fun31090({key, millisecondsInUnit}) { // fn#31090, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:3510, offset: 0x00ff323e, size: 80 bytes, params: 2, frame: 15
const binding = env0_0;
const Math = global.Math;
binding[key] = Math.floor(env0_1 / millisecondsInUnit);
env0_1 = env0_1 - env0_0[key] * millisecondsInUnit;
}
}
function unitsAsStrings(a0, a1) { // fn#31091, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:3597, offset: 0x00ff328e, size: 261 bytes, params: 3, frame: 19
const intl = (IndexNativeModule).intl;
return a0.days > 0 ? intl.formatToPlainString(a1.days, {days: a0.days,
hours: a0.hours}) : a0.hours > 0 ? intl.formatToPlainString(a1.hours, {hours: a0.hours,
minutes: a0.minutes}) : intl.formatToPlainString(a1.minutes, {minutes: global.Math.max(1, a0.minutes)});
}
function getMonthlyProgressPercentage() { // fn#31092, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:3932, offset: 0x00ff3393, size: 103 bytes, params: 1, frame: 16
let value = getESTDate();
const Date = global.Date;
const date = new Date(value.getFullYear(), value.getMonth() + 1, 0);
let getDate = date.getDate;
const value7 = Reflect.apply(getDate, date, []);
getDate = value.getDate;
value = Reflect.apply(getDate, value, []) / value7;
return value * 100;
}
function getDaysRemainingInMonth() { // fn#31093, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:4098, offset: 0x00ff33fa, size: 96 bytes, params: 1, frame: 16
const eSTDate = getESTDate();
const Date = global.Date;
const date = new Date(eSTDate.getFullYear(), eSTDate.getMonth() + 1, 0);
let getDate = date.getDate;
const value7 = Reflect.apply(getDate, date, []);
getDate = eSTDate.getDate;
return value7 - Reflect.apply(getDate, eSTDate, []);
}
function formatDateForDatetimeLocal(a0) { // fn#31094, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3965:4254, offset: 0x00ff345a, size: 48 bytes, params: 2, frame: 12
var r0;
let value = '';
if (a0 == null) {
r0 = value;
} else {
value = dateStringToMoment(a0);
value = value.format('YYYY-MM-DDTHH:mm');
r0 = value;
}
return r0;
}
}
global.__d(_fun31072, 3826, [1949, 3, 3827, 3829, 1314, 3843, 1244, 694, 3845, 3738,
2]) /* metro module 3826, dependencies: [1949, 3, 3827, 3829, 1314, 3843, 1244, 694, 3845, 3738, 2] */;