1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Saturate day of month in datepicker

Summary:
The datepicker could step by the wrong number of months, due to the date rolling over to the next month when the number of days in the month is exceeded. For example, going forward from January 31 would jump to March 3, while going backward from July 31 would only go to July 1.

Push the date back to ensure that the datepicker stays in the correct month when switching.

Test Plan: Changed months starting from an assortment of dates.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: artms, Korvin

Differential Revision: https://secure.phabricator.com/D21673
This commit is contained in:
Dmitri Iouchtchenko 2021-06-13 14:37:28 -04:00
parent 51cb7a3db9
commit 1b54afdce5
2 changed files with 16 additions and 9 deletions

View file

@ -481,7 +481,7 @@ return array(
'rsrc/js/core/behavior-detect-timezone.js' => '78bc5d94', 'rsrc/js/core/behavior-detect-timezone.js' => '78bc5d94',
'rsrc/js/core/behavior-device.js' => 'ac2b1e01', 'rsrc/js/core/behavior-device.js' => 'ac2b1e01',
'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '7ad020a5', 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '7ad020a5',
'rsrc/js/core/behavior-fancy-datepicker.js' => '956f3eeb', 'rsrc/js/core/behavior-fancy-datepicker.js' => '36821f8d',
'rsrc/js/core/behavior-form.js' => '55d7b788', 'rsrc/js/core/behavior-form.js' => '55d7b788',
'rsrc/js/core/behavior-gesture.js' => 'b58d1a2a', 'rsrc/js/core/behavior-gesture.js' => 'b58d1a2a',
'rsrc/js/core/behavior-global-drag-and-drop.js' => '1cab0e9a', 'rsrc/js/core/behavior-global-drag-and-drop.js' => '1cab0e9a',
@ -635,7 +635,7 @@ return array(
'javelin-behavior-editengine-reorder-configs' => '4842f137', 'javelin-behavior-editengine-reorder-configs' => '4842f137',
'javelin-behavior-editengine-reorder-fields' => '0ad8d31f', 'javelin-behavior-editengine-reorder-fields' => '0ad8d31f',
'javelin-behavior-event-all-day' => '0b1bc990', 'javelin-behavior-event-all-day' => '0b1bc990',
'javelin-behavior-fancy-datepicker' => '956f3eeb', 'javelin-behavior-fancy-datepicker' => '36821f8d',
'javelin-behavior-global-drag-and-drop' => '1cab0e9a', 'javelin-behavior-global-drag-and-drop' => '1cab0e9a',
'javelin-behavior-harbormaster-log' => 'b347a301', 'javelin-behavior-harbormaster-log' => 'b347a301',
'javelin-behavior-herald-rule-editor' => '0922e81d', 'javelin-behavior-herald-rule-editor' => '0922e81d',
@ -1229,6 +1229,13 @@ return array(
'aphront-typeahead-control-css', 'aphront-typeahead-control-css',
'phui-tag-view-css', 'phui-tag-view-css',
), ),
'36821f8d' => array(
'javelin-behavior',
'javelin-util',
'javelin-dom',
'javelin-stratcom',
'javelin-vector',
),
'3829a3cf' => array( '3829a3cf' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-uri', 'javelin-uri',
@ -1781,13 +1788,6 @@ return array(
'javelin-vector', 'javelin-vector',
'javelin-stratcom', 'javelin-stratcom',
), ),
'956f3eeb' => array(
'javelin-behavior',
'javelin-util',
'javelin-dom',
'javelin-stratcom',
'javelin-vector',
),
'9623adc1' => array( '9623adc1' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',

View file

@ -424,6 +424,13 @@ JX.behavior('fancy-datepicker', function(config, statics) {
value_m += 12; value_m += 12;
value_y--; value_y--;
} }
// This relies on months greater than 11 rolling over into the next
// year and days less than 1 rolling back into the previous month.
var last_date = new Date(value_y, value_m, 0);
if (value_d > last_date.getDate()) {
// The date falls outside the new month, so stuff it back in.
value_d = last_date.getDate();
}
break; break;
case 'd': case 'd':
// User clicked a day. // User clicked a day.