MCPcopy Index your code
hub / github.com/MALSync/MALSync / getRelativeText

Method getRelativeText

src/utils/IntlWrapper.ts:144–161  ·  view source on GitHub ↗
(options: DurationFormatOptions = { style: 'narrow' })

Source from the content-addressed store, hash-verified

142 }
143
144 getRelativeText(options: DurationFormatOptions = { style: 'narrow' }): string {
145 if (!this.duration) return '';
146 if (this.isFallback) return timeToString(this.duration);
147 const newOptions: DurationFormatOptions = options;
148 if (options.style === 'significantLongNarrow') {
149 const keys = Object.keys(dateUnitToMs);
150 for (let i = 0; i < keys.length; i++) {
151 const key = keys[i];
152 if (this.duration[key]) {
153 newOptions[key] = 'long';
154 newOptions.style = 'narrow';
155 break;
156 }
157 }
158 }
159 // @ts-expect-error surely it works
160 return new Intl.DurationFormat(this.locale, newOptions).format(this.duration);
161 }
162
163 getDuration() {
164 return this.duration;

Callers 9

getRelativeNowTextMethod · 0.95
infoMethod · 0.80
infoMethod · 0.80
infoMethod · 0.80
infoMethod · 0.80
infoMethod · 0.80
infoMethod · 0.80

Calls 3

timeToStringFunction · 0.85
keysMethod · 0.80
formatMethod · 0.80

Tested by

no test coverage detected