Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React from 'react';
import Moment from 'react-moment';
import moment from 'moment/min/moment-with-locales';
import 'moment/locale/sv';
import { Text } from 'react-native';
import momentTZ from 'moment-timezone';
import 'moment-timezone';
import { getTimezone } from '@helpers/device';
import PropTypes from 'prop-types';
import I18n from 'react-native-i18n';
Moment.globalElement = Text;
Moment.startPooledTimer();
const changeFormat = (format) => {
if (format.includes('DD')) {
return format.replace('DD', 'MMM').replace('MMM', 'DD');
} else if (format.includes('Do')) {
return format.replace('Do', 'MMM').replace('MMM', 'Do');
}
return format;
};
export const isToday = dateTime => (moment(new Date(dateTime)).format('YYYYMMDD') === moment().format('YYYYMMDD'));
export const isWithinAWeek = dateTime => moment(new Date(dateTime)).isAfter(moment().subtract(7, 'days'));
export const isBeforeAWeek = dateTime => moment(new Date(dateTime)).isBefore(moment().subtract(7, 'days'));