(options: DurationFormatOptions = { style: 'narrow' })
| 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; |
no test coverage detected