diff options
| author | rating89us <45968869+rating89us@users.noreply.github.com> | 2021-06-15 13:44:47 +0200 |
|---|---|---|
| committer | rating89us <rating89us@rating89us.com> | 2021-06-15 16:34:07 +0200 |
| commit | dfe8146f5c48b8ea67c417b9e2b406c1ef80a3a7 (patch) | |
| tree | 912eaef9d321657bc1b019aee4f0af8aa06cf7ea /js | |
| parent | 7c379e2cdaafc0cd618dbaab466625aa76c918bf (diff) | |
| download | monzero-gui-dfe8146f5c48b8ea67c417b9e2b406c1ef80a3a7.tar.gz monzero-gui-dfe8146f5c48b8ea67c417b9e2b406c1ef80a3a7.tar.xz monzero-gui-dfe8146f5c48b8ea67c417b9e2b406c1ef80a3a7.zip | |
SettingsInfo, WizardRestoreWallet1, WizardCreateDevice1: Correct restore height date when typed in wrong format
Diffstat (limited to 'js')
| -rw-r--r-- | js/Utils.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/js/Utils.js b/js/Utils.js index 61f4509b..88b0f66a 100644 --- a/js/Utils.js +++ b/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; +} |
