Skip to content

Commit

Permalink
datepicker timezone problem bugfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
canpolatoral committed May 8, 2019
1 parent 5f41811 commit ff95a7a
Show file tree
Hide file tree
Showing 3 changed files with 7 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 @@ -663,8 +663,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 @@ -676,21 +675,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
6 changes: 6 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

0 comments on commit ff95a7a

Please sign in to comment.