Page MenuHomePhabricator

D18383.id44187.diff
No OneTemporary

D18383.id44187.diff

diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -484,7 +484,7 @@
'rsrc/js/core/behavior-device.js' => 'bb1dd507',
'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '484a6e22',
'rsrc/js/core/behavior-error-log.js' => '6882e80a',
- 'rsrc/js/core/behavior-fancy-datepicker.js' => 'a9210d03',
+ 'rsrc/js/core/behavior-fancy-datepicker.js' => 'ecf4e799',
'rsrc/js/core/behavior-file-tree.js' => '88236f00',
'rsrc/js/core/behavior-form.js' => '5c54cbf3',
'rsrc/js/core/behavior-gesture.js' => '3ab51e2c',
@@ -633,7 +633,7 @@
'javelin-behavior-editengine-reorder-fields' => 'b59e1e96',
'javelin-behavior-error-log' => '6882e80a',
'javelin-behavior-event-all-day' => 'b41537c9',
- 'javelin-behavior-fancy-datepicker' => 'a9210d03',
+ 'javelin-behavior-fancy-datepicker' => 'ecf4e799',
'javelin-behavior-global-drag-and-drop' => '960f6a39',
'javelin-behavior-herald-rule-editor' => '7ebaeed3',
'javelin-behavior-high-security-warning' => 'a464fe03',
@@ -1716,13 +1716,6 @@
'javelin-uri',
'phabricator-keyboard-shortcut',
),
- 'a9210d03' => array(
- 'javelin-behavior',
- 'javelin-util',
- 'javelin-dom',
- 'javelin-stratcom',
- 'javelin-vector',
- ),
'a9f88de2' => array(
'javelin-behavior',
'javelin-dom',
@@ -2105,6 +2098,13 @@
'javelin-dom',
'phabricator-draggable-list',
),
+ 'ecf4e799' => array(
+ 'javelin-behavior',
+ 'javelin-util',
+ 'javelin-dom',
+ 'javelin-stratcom',
+ 'javelin-vector',
+ ),
'edf8a145' => array(
'javelin-behavior',
'javelin-uri',
diff --git a/webroot/rsrc/js/core/behavior-fancy-datepicker.js b/webroot/rsrc/js/core/behavior-fancy-datepicker.js
--- a/webroot/rsrc/js/core/behavior-fancy-datepicker.js
+++ b/webroot/rsrc/js/core/behavior-fancy-datepicker.js
@@ -287,26 +287,38 @@
};
function getValidDate() {
- var written_date = new Date(value_y, value_m-1, value_d);
+ var year_int = parseInt(value_y, 10);
- if (isNaN(written_date.getTime())) {
+ if (isNaN(year_int) || year_int < 0) {
return new Date();
- } else {
- //year 01 should be 2001, not 1901
- if (written_date.getYear() < 70) {
- value_y += 2000;
- written_date = new Date(value_y, value_m-1, value_d);
- }
+ }
- // adjust for a date like February 31
- var adjust = 1;
- while (written_date.getMonth() !== value_m-1) {
- written_date = new Date(value_y, value_m-1, value_d-adjust);
- adjust++;
- }
+ // If the user enters "11" for the year, interpret it as "2011" (which
+ // is almost certainly what they mean) not "1911" (which is the default
+ // behavior of Javascript).
+ if (year_int < 70) {
+ year_int += 2000;
+ }
+
+ var month_int = parseInt(value_m, 10);
+ if (isNaN(month_int) || month_int < 1 || month_int > 12) {
+ return new Date();
+ }
+
+ // In Javascript, January is "0", not "1", so adjust the value down.
+ month_int = month_int - 1;
+
+ var day_int = parseInt(value_d, 10);
+ if (isNaN(day_int) || day_int < 1 || day_int > 31) {
+ return new Date();
+ }
- return written_date;
+ var written_date = new Date(year_int, month_int, day_int);
+ if (isNaN(written_date.getTime())) {
+ return new Date();
}
+
+ return written_date;
}

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 24, 12:11 AM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7719253
Default Alt Text
D18383.id44187.diff (3 KB)

Event Timeline