Skip to content

Commit

Permalink
Release 7.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
arigatopavel committed Nov 11, 2021
1 parent 996ca21 commit 3c188ef
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change history for ui-calendar

## [7.0.1] (https://github.com/folio-org/ui-calendar/tree/v7.0.1) (2021-11-11)
[Full Changelog](https://github.com/folio-org/ui-calendar/compare/v7.0.0...v7.0.1)

* Fix long exception periods display wrong days and subsequent exception periods display on the wrong days. Refs UICAL-175.

## [7.0.0] (https://github.com/folio-org/ui-calendar/tree/v7.0.0) (2021-09-30)
[Full Changelog](https://github.com/folio-org/ui-calendar/compare/v6.1.2...v7.0.0)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/calendar",
"version": "7.0.0",
"version": "7.0.1",
"description": "Opening hours",
"repository": "folio-org/ui-calendar",
"publishConfig": {
Expand Down
12 changes: 5 additions & 7 deletions src/settings/OpenExceptionalForm/ExceptionWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ import {
ALL_DAY,
} from '../constants';

import {
OFFSET_HOURS,
} from '../utils/time';
import { setTimezoneOffset } from '../utils/time';

class ExceptionWrapper extends Component {
static propTypes = {
Expand Down Expand Up @@ -366,9 +364,8 @@ class ExceptionWrapper extends Component {

for (let i = 0; i < moment(end)
.diff(moment(start), 'days') + 1; i++) {
const today = moment(start)
const today = setTimezoneOffset(start)
.add(i, 'days')
.add(OFFSET_HOURS, 'hours')
.format('dddd')
.toUpperCase();

Expand Down Expand Up @@ -460,10 +457,11 @@ class ExceptionWrapper extends Component {
{eventContent}
</div>;

const eventStart = setTimezoneOffset(start).add(i, 'days');
const tempObj = {
id,
end: moment(start).add(i, 'days'),
start: moment(start).add(i, 'days'),
end: eventStart.clone(),
start: eventStart,
title: eventTitle,
exceptional,
};
Expand Down
10 changes: 0 additions & 10 deletions src/settings/OpenExceptionalForm/ExceptionalBigCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import {
momentLocalizer,
} from 'react-big-calendar';

import {
OFFSET_HOURS,
} from '../utils/time';

const localizer = momentLocalizer(moment);

class ExceptionalBigCalendar extends Component {
Expand All @@ -18,10 +14,6 @@ class ExceptionalBigCalendar extends Component {
getEvent: PropTypes.func.isRequired,
};

accessor = (date) => {
return moment(date).clone().add(OFFSET_HOURS, 'hours').toDate();
}

render() {
const {
myEvents,
Expand All @@ -39,8 +31,6 @@ class ExceptionalBigCalendar extends Component {
views={['month']}
onSelectEvent={getEvent}
style={{ height: '90vh' }}
startAccessor={(event) => this.accessor(event.start)}
endAccessor={(event) => this.accessor(event.end)}
/>
);
}
Expand Down
9 changes: 8 additions & 1 deletion src/settings/utils/time.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
import moment from 'moment';

// eslint-disable-next-line import/prefer-default-export
export const OFFSET_HOURS = (new Date().getTimezoneOffset()) / 60;
export const setTimezoneOffset = (date) => {
const momentDate = moment(date);
const utcOffset = -(momentDate.utcOffset() / 60);

return momentDate.add(utcOffset, 'hours');
};

0 comments on commit 3c188ef

Please sign in to comment.