remove unnecessary utility function

This commit is contained in:
Mike Greiling 2017-01-02 14:48:58 -06:00
parent 4d2fbe65cd
commit e4883e7efc
2 changed files with 3 additions and 17 deletions

View file

@ -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';

View file

@ -1,4 +1,4 @@
/* 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');
};