Skip to content

Commit

Permalink
No longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
sunafterrainwm committed Feb 9, 2022
1 parent 59369c0 commit c36b0ae
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ export interface MwnDateStatic {
populateLocaleData(lang?: string): Promise<void>;
}

type startWith<S extends string, O extends Record<string, any>> = {
[key in keyof O]: key extends `${S}${string}` ? O[key] : never;
};

export default function (bot: mwn) {
class XDate extends Date implements MwnDate {
constructor(...args: ConstructorParameters<DateConstructor>);
Expand Down Expand Up @@ -378,18 +374,6 @@ export default function (bot: mwn) {
}
}

// Tweak set* methods (setHours, setUTCMinutes, etc) so that they
// return the modified XDate object rather than the seconds-since-epoch
// representation which is what JS Date() gives
(<(keyof startWith<'set', XDate>)[]>Object.getOwnPropertyNames(Date.prototype))
.filter((f) => typeof f === 'string' && f.startsWith('set'))
.forEach((func) => {
let proxy = XDate.prototype[func];
XDate.prototype[func] = function (...args: Parameters<XDate[typeof func]>) {
return proxy.call(this, ...args);
};
});

return XDate as MwnDateStatic;
}

Expand Down

0 comments on commit c36b0ae

Please sign in to comment.