mirror of
https://github.com/oleid/gnome-shell-teatime.git
synced 2022-04-29 18:53:50 +00:00
workaround for leading zeros causing failure in string to int conversion in older gnome-shell versions
This commit is contained in:
parent
60a8f34563
commit
241a3dc475
@ -253,16 +253,16 @@ const TeaTime = new Lang.Class({
|
||||
let seconds = 0;
|
||||
let match = customTime.match(/^(?:(\d+)(?::(\d{0,2}))?|:(\d+))$/)
|
||||
if (match) {
|
||||
if (match[3])
|
||||
seconds = parseInt(match[3]);
|
||||
else {
|
||||
if (match[1])
|
||||
seconds += parseInt(match[1]) * 60;
|
||||
if (match[2])
|
||||
seconds += parseInt(match[2]);
|
||||
let factor = 1;
|
||||
for (var i = match.length-2; i > 0; i--) {
|
||||
let s = match[i].replace(/^0/,''); // fix for elder GNOME <= 3.10 which don't like leading zeros
|
||||
seconds += factor * parseInt(s);
|
||||
factor *= 60;
|
||||
}
|
||||
if (seconds > 0) {
|
||||
this._initCountdown(seconds);
|
||||
this.menu.close();
|
||||
}
|
||||
this._initCountdown(seconds);
|
||||
this.menu.close();
|
||||
}
|
||||
this._customEntry.set_text("");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user