Skip to content

Commit

Permalink
Merge pull request #123 from canpolatoral/master
Browse files Browse the repository at this point in the history
 datepicker timezone problem bugfix.
  • Loading branch information
canpolatoral authored May 8, 2019
2 parents 7a8565d + 6eb7a6e commit 28885b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
11 changes: 0 additions & 11 deletions packages/components/src/DateTimePicker/DateTimePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import {
getDatePickerStyle,
getDefaultDate,
getDateToString,
clearTime,
// clearTimeZone,
clearJustTimeZone,
checkDateForBusiness,
} from './dateUtils';

Expand Down Expand Up @@ -252,8 +249,6 @@ class DateTimePicker extends ComponentBase {
} else {
handleDate = new Date();
handleDate.setDate(handleDate.getDate() - 1);
handleDate = clearTime(handleDate);
handleDate = clearJustTimeZone(handleDate);
handleDate = this.dateUpdate(handleDate, handleDate, -1);
this.dateOnChange(e, handleDate, true);
}
Expand All @@ -270,8 +265,6 @@ class DateTimePicker extends ComponentBase {
} else {
handleDate = new Date();
handleDate.setDate(handleDate.getDate() + 1);
handleDate = clearTime(handleDate);
handleDate = clearJustTimeZone(handleDate);
handleDate = this.dateUpdate(handleDate, handleDate, 1);
this.dateOnChange(e, handleDate, true);
}
Expand All @@ -290,13 +283,9 @@ class DateTimePicker extends ComponentBase {

getValue() {
if (this.state.value) {
// TODO: timezone farkı kaldırılması gerekiyor.
// return new Date((this.state.value).getTime());
const formats = getFormatDecomposition(this.props.format);
const returnDate = this.state.value;
// sadece tarih gösterilecek ise saat bilgileri temizleniyor.
if (formats.timeFormat === undefined) {
clearTime(returnDate);
return returnDate;
}
return returnDate;
Expand Down
18 changes: 1 addition & 17 deletions packages/components/src/DateTimePicker/dateUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,7 @@ export function getDefaultDate(props) {
export function getDateToString(propDate, defaultDate) {
let returnDate = defaultDate;
if (isString(propDate)) {
let clearedDate = clearTimeZone(propDate);
returnDate = clearedDate;
returnDate = new Date(propDate);
if (isNaN(returnDate)) {
returnDate = defaultDate;
}
Expand All @@ -679,21 +678,6 @@ export function getDateToString(propDate, defaultDate) {
}
return returnDate;
}
export function clearTime(returnDate) {
returnDate.setHours(0);
returnDate.setMinutes(0);
returnDate.setSeconds(0);

return returnDate;
}
export function clearTimeZone(returnDate) {
if (isString(returnDate))
returnDate = new Date(returnDate);
return new Date((returnDate).getTime() + ((returnDate).getTimezoneOffset() * 60000));
}
export function clearJustTimeZone(returnDate) {
return new Date(returnDate.getTime());
}
export function getDayList(calendarInfo, selectedDate, dayType, betweenDayCount) {
// let monthFirstDate = cloneDate(getFirstDayOfMonth(selectedDate));
const specialDayStringArray = [];
Expand Down
9 changes: 9 additions & 0 deletions packages/utils/src/Localization/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import phoneFormatter from 'phone-formatter';
import 'numeral/locales';
import { Language } from './language';

/* eslint-disable */
Date.prototype.toJSON = function() {
return Moment(this).format();
};
/* eslint-enable */

export class Localization {
static language = 'en';

Expand Down Expand Up @@ -111,6 +117,7 @@ export class Localization {
}

static getDateTimeFormat(format) {
// eslint-disable-next-line no-underscore-dangle
return moment.localeData()._longDateFormat[format];
}

Expand All @@ -127,10 +134,12 @@ export class Localization {
}

static getFloatValue(value) {
// eslint-disable-next-line no-underscore-dangle
return numeral(value)._value;
}

static getIntegerValue(value) {
// eslint-disable-next-line no-underscore-dangle
return parseInt(numeral(value)._value, 10);
}

Expand Down

0 comments on commit 28885b0

Please sign in to comment.