mirror of
https://github.com/monero-project/monero-gui.git
synced 2026-04-01 22:57:25 -04:00
SettingsInfo, WizardRestoreWallet1, WizardCreateDevice1: Correct restore height date when typed in wrong format
This commit is contained in:
15
js/Utils.js
15
js/Utils.js
@@ -115,3 +115,18 @@ function capitalize(s){
|
||||
function removeTrailingZeros(value) {
|
||||
return (value + '').replace(/(\.\d*?)0+$/, '$1').replace(/\.$/, '');
|
||||
}
|
||||
|
||||
function parseDateStringOrRestoreHeightAsInteger(value) {
|
||||
// Parse date string or restore height as integer
|
||||
var restoreHeight = 0;
|
||||
if (value.indexOf('-') === 4 && value.length === 10) {
|
||||
restoreHeight = Wizard.getApproximateBlockchainHeight(value, Utils.netTypeToString());
|
||||
} else if (parseInt(value.substring(0, 4)) >= 2014 && parseInt(value.substring(0, 4)) <= 2025 && value.length === 8) {
|
||||
// Correct date typed in a wrong format (20201225 instead of 2020-12-25)
|
||||
var restoreHeightHyphenated = value.substring(0, 4) + "-" + value.substring(4, 6) + "-" + value.substring(6, 8);
|
||||
restoreHeight = Wizard.getApproximateBlockchainHeight(restoreHeightHyphenated, Utils.netTypeToString());
|
||||
} else {
|
||||
restoreHeight = parseInt(value);
|
||||
}
|
||||
return restoreHeight;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user