mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Improve date picker MMDD shorthand
This commit is contained in:
parent
b1522742cc
commit
e9a4b43268
@ -36,7 +36,7 @@ Some fields also allow to select a value by scanning a barcode. It works best wh
|
||||
### Input shorthands for date fields
|
||||
For (productivity) reasons all date (and time) input fields use the ISO-8601 format regardless of localization.
|
||||
The following shorthands are available:
|
||||
- `MMDD` gets expanded to the given day on the current year in proper notation
|
||||
- `MMDD` gets expanded to the given day on the current year, if > today, or to the given day next year, if < today, in proper notation
|
||||
- Example: `0517` will be converted to `2018-05-17`
|
||||
- `YYYYMMDD` gets expanded to the proper ISO-8601 notation
|
||||
- Example: `20190417` will be converted to `2019-04-17`
|
||||
|
@ -93,7 +93,12 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e)
|
||||
}
|
||||
else if (value.length === 4 && !(Number.parseInt(value) > centuryStart && Number.parseInt(value) < centuryEnd))
|
||||
{
|
||||
Grocy.Components.DateTimePicker.SetValue((new Date()).getFullYear().toString() + value);
|
||||
var date = moment((new Date()).getFullYear().toString() + value);
|
||||
if (date.isBefore(moment()))
|
||||
{
|
||||
date.add(1, "year");
|
||||
}
|
||||
Grocy.Components.DateTimePicker.SetValue(date.format(format));
|
||||
nextInputElement.focus();
|
||||
}
|
||||
else if (value.length === 8 && $.isNumeric(value))
|
||||
|
Loading…
x
Reference in New Issue
Block a user