mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 02:13:48 +00:00
feat: improve smart time entry (#2029)
Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
This commit is contained in:
committed by
GitHub
parent
8c52556cc0
commit
4662cc8a26
@@ -116,12 +116,14 @@ function checkMatchers(value: string): number | null {
|
||||
// if there's a number after 'h' without a unit and it's not followed by 's', treat it as minutes
|
||||
const implicitMinutesValue = hoursMatch?.[2] ? parse(hoursMatch[2]) : 0;
|
||||
|
||||
const minutesMatch = /(\d+)m/i.exec(value);
|
||||
const minutesMatch = /(\d+)m(?:(\d+)?)/i.exec(value);
|
||||
// only use implicit minutes if there's no explicit minutes match
|
||||
const minutesMatchValue = minutesMatch ? parse(minutesMatch[1]) : implicitMinutesValue;
|
||||
// if there's a number after 'm' without a unit treat it as seconds
|
||||
const implicitSecondsValue = minutesMatch?.[2] ? parse(minutesMatch[2]) : 0;
|
||||
|
||||
const secondsMatch = /(\d+)s/i.exec(value);
|
||||
const secondsMatchValue = secondsMatch ? parse(secondsMatch[1]) : 0;
|
||||
const secondsMatchValue = secondsMatch ? parse(secondsMatch[1]) : implicitSecondsValue;
|
||||
|
||||
if (hoursMatch || minutesMatch || secondsMatch) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user