Commit e4883e7e authored by Mike Greiling's avatar Mike Greiling

remove unnecessary utility function

parent 4d2fbe65
......@@ -83,9 +83,8 @@
this.rawSelectedDate = $(`input[name='${this.fieldName}']`).val();
if (this.rawSelectedDate.length) {
// Avoid time zone inconsistency using the utils.createDateObject
// method, instead of the native Date object.
const dateObj = gl.utils.createDateObject(this.rawSelectedDate);
const dateArray = this.rawSelectedDate.split('-').map(v => parseInt(v, 10));
const dateObj = new Date(dateArray[0], dateArray[1] - 1, dateArray[2]);
this.displayedDate = $.datepicker.formatDate('M d, yy', dateObj);
} else {
this.displayedDate = 'No due date';
......
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, no-param-reassign, no-cond-assign, comma-dangle, no-unused-expressions, prefer-template, prefer-arrow-callback, padded-blocks, max-len */
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, no-param-reassign, no-cond-assign, comma-dangle, no-unused-expressions, prefer-template, padded-blocks, max-len */
/* global timeago */
/* global dateFormat */
......@@ -16,19 +16,6 @@
}
w.gl.utils.days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
// createDateObject must be used instead of using native Date object
// to create a new Date instance using string as param - '2016-11-10' or
// '2016/11/10' in order to avoid time zone inconsistency.
w.gl.utils.createDateObject = function(string) {
var dateSeparator = string.indexOf('-') > -1 ? '-' : '/';
var dateArray = string.split(dateSeparator).map(function(dateItem) {
return parseInt(dateItem, 10);
});
return new Date(dateArray[0], dateArray[1] - 1, dateArray[2]);
};
w.gl.utils.formatDate = function(datetime) {
return dateFormat(datetime, 'mmm d, yyyy h:MMtt Z');
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment