Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/ChangeDueDateDialog/ChangeDueDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import React from 'react';
import PropTypes from 'prop-types';
import { get, isEqual, pickBy } from 'lodash';
import { FormattedMessage } from 'react-intl';
import moment from 'moment-timezone';

import { Button, Icon, Layout } from '@folio/stripes-components';
import { Button, Icon, Layout, dayjs } from '@folio/stripes-components';

import DueDatePicker from './DueDatePicker';
import LoanList from './LoanList';
Expand All @@ -27,8 +26,8 @@ class ChangeDueDate extends React.Component {
}

static newDueDateIsInThePast(props, state) {
const requestedDueDate = moment(state.datetime);
const currentDate = moment.tz('UTC');
const requestedDueDate = dayjs(state.datetime);
const currentDate = dayjs.tz('UTC');

return requestedDueDate.isBefore(currentDate);
}
Expand All @@ -38,8 +37,8 @@ class ChangeDueDate extends React.Component {

if (!user || !user.expirationDate) return false;

const requestedDueDate = moment(state.datetime);
const userExpirationDate = moment(user.expirationDate);
const requestedDueDate = dayjs(state.datetime);
const userExpirationDate = dayjs(user.expirationDate);

return userExpirationDate.isBefore(requestedDueDate);
}
Expand Down
5 changes: 2 additions & 3 deletions lib/ChangeDueDateDialog/DueDatePicker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import moment from 'moment-timezone';
import { injectIntl } from 'react-intl';

import { dayjs } from '@folio/stripes-components';
import DueDatePickerForm from './DueDatePickerForm';

class DueDatePicker extends React.Component {
Expand Down Expand Up @@ -43,7 +42,7 @@ class DueDatePicker extends React.Component {
const date = values.date.split('T')[0];
const time = values.time.split(/[Z+-]/)[0];

const localDatetime = moment.tz(`${date}T${time}`, timeZone);
const localDatetime = dayjs.tz(`${date}T${time}`, timeZone);
const utcDatetime = localDatetime.tz('UTC').format();

this.props.onChange(utcDatetime);
Expand Down
6 changes: 3 additions & 3 deletions lib/ProxyManager/proxyUtil.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { get } from 'lodash';
import moment from 'moment'; // eslint-disable-line import/no-extraneous-dependencies
import { dayjs } from '@folio/stripes-components';

export function isProxyExpired(user, proxyMap) {
const proxy = proxyMap[user.id];
return proxy && proxy.expirationDate &&
moment(proxy.expirationDate).isSameOrBefore(new Date());
dayjs(proxy.expirationDate).isSameOrBefore(new Date());
}

export function isSponsorExpired(sponsor) {
return sponsor && sponsor.expirationDate &&
moment(sponsor.expirationDate).isSameOrBefore(new Date());
dayjs(sponsor.expirationDate).isSameOrBefore(new Date());
}

export function isRequestForSponsorInvalid(user, proxyMap) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import moment from 'moment';
import { dayjs } from '@folio/stripes-components';

export const isDateValid = (date, dateFormat) => {
const momentDateWrapper = moment(date, dateFormat, true);
const dayjsDateWrapper = dayjs(date, dateFormat, true);

return momentDateWrapper.isValid();
return dayjsDateWrapper.isValid();
};

export const validateDateRange = (dateRange, dateFormat) => {
Expand All @@ -12,8 +12,8 @@ export const validateDateRange = (dateRange, dateFormat) => {
endDate,
} = dateRange;

const startDateMomentWrapper = moment(startDate, dateFormat, true);
const endDateMomentWrapper = moment(endDate, dateFormat, true);
const startDateDayJSWrapper = dayjs(startDate, dateFormat, true);
const endDateDayJSWrapper = dayjs(endDate, dateFormat, true);

const startDateEmpty = startDate === '';
const endDateEmpty = endDate === '';
Expand All @@ -25,7 +25,7 @@ export const validateDateRange = (dateRange, dateFormat) => {
const endDateInvalid = !endDateEmpty && !isDateValid(endDate, dateFormat);
const bothDatesValid = !startDateInvalid && !endDateInvalid;

const wrongDatesOrder = bothDatesValid && startDateMomentWrapper.isAfter(endDateMomentWrapper);
const wrongDatesOrder = bothDatesValid && startDateDayJSWrapper.isAfter(endDateDayJSWrapper);

const dateRangeValid = bothDatesEntered && bothDatesValid && !wrongDatesOrder;

Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"inflected": "^2.0.4",
"miragejs": "^0.1.40",
"mocha": "^10.2.0",
"moment": "^2.29.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intl": "^6.4.4",
Expand All @@ -83,7 +82,6 @@
"final-form": "^4.18.2",
"final-form-arrays": "^3.0.2",
"lodash": "^4.17.4",
"moment-timezone": "^0.5.17",
"prop-types": "^15.5.10",
"prop-types-extra": "^1.1.0",
"query-string": "^7.1.2",
Expand Down