How to use react-moment - 3 common examples

To help you get started, we’ve selected a few react-moment examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prymitive / karma / ui / src / index.tsx View on Github external
import Moment from "react-moment";

import {
  SettingsElement,
  SetupSentry,
  ParseDefaultFilters,
  ParseUIDefaults
} from "./AppBoot";
import { App } from "./App";

SetupSentry(SettingsElement());

// global timer for updating timestamps to human readable offsets
// this needs to be run before any  instance
// https://www.npmjs.com/package/react-moment#pooled-timer
Moment.startPooledTimer();

// https://wetainment.com/testing-indexjs/
export default ReactDOM.render(
  ,
  document.getElementById("root")
);
github Skjutsgruppen / skjutsgruppen-reactnative / app / components / date.js View on Github external
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'));
github Skjutsgruppen / skjutsgruppen-reactnative / app / components / date.js View on Github external
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'));

react-moment

React component for the moment date library.

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis