mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-30 01:25:38 -05:00
Fixing bug where if copy duration went over 24h it would reset to 00:00:00 (#23290)
* Fixing bug where if copy duration went over 24h it would reset to 00:00:00
This commit is contained in:
@@ -101,7 +101,7 @@ const _dateFormatter = new Intl.DateTimeFormat(
|
||||
second: '2-digit'
|
||||
});
|
||||
|
||||
const _numberFormatter = new Intl.NumberFormat(
|
||||
const _numberFormatterOneMinIntegers = new Intl.NumberFormat(
|
||||
undefined, {
|
||||
style: 'decimal',
|
||||
useGrouping: true,
|
||||
@@ -110,6 +110,31 @@ const _numberFormatter = new Intl.NumberFormat(
|
||||
maximumFractionDigits: 0,
|
||||
});
|
||||
|
||||
const _numberFormatterTwoMinIntegers = new Intl.NumberFormat(
|
||||
undefined, {
|
||||
style: 'decimal',
|
||||
useGrouping: true,
|
||||
minimumIntegerDigits: 2,
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 0,
|
||||
});
|
||||
|
||||
export function formatSecondsIntoReadableTime(seconds: number) {
|
||||
const hours = seconds / (60 * 60);
|
||||
const absoluteHours = Math.floor(hours);
|
||||
const h = _numberFormatterTwoMinIntegers.format(absoluteHours);
|
||||
|
||||
const minutesRemaining = (hours - absoluteHours) * 60;
|
||||
const absoluteMinutes = Math.floor(minutesRemaining);
|
||||
const m = _numberFormatterTwoMinIntegers.format(absoluteMinutes);
|
||||
|
||||
const secondsRemaining = (minutesRemaining - absoluteMinutes) * 60;
|
||||
const absoluteSeconds = Math.floor(secondsRemaining);
|
||||
const s = _numberFormatterTwoMinIntegers.format(absoluteSeconds);
|
||||
|
||||
return h + ':' + m + ':' + s;
|
||||
}
|
||||
|
||||
export function formatDateTimeString(dateTime: string): string {
|
||||
return dateTime
|
||||
? _dateFormatter.format(new Date(dateTime))
|
||||
@@ -129,7 +154,7 @@ export function formatTime(miliseconds: number): string {
|
||||
|
||||
export function formatNumber(value: number): string {
|
||||
return value >= 0
|
||||
? _numberFormatter.format(value)
|
||||
? _numberFormatterOneMinIntegers.format(value)
|
||||
: '';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user