How to use @date-io/moment - 3 common examples

To help you get started, we’ve selected a few @date-io/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 mapseed / platform / src / base / static / components / molecules / form-field-modules / date-field.tsx View on Github external
import { FieldProps as FormikFieldProps } from "formik";
import MomentUtils from "@date-io/moment";
import { MuiPickersUtilsProvider, DatePicker } from "@material-ui/pickers";
import { DatePickerView } from "@material-ui/pickers/DatePicker/DatePicker";

import { MapseedDateFieldModule } from "../../../state/ducks/forms";
import { FieldPrompt } from "../../atoms/typography";
import { CheckboxInput } from "../../atoms/input";

type DateFieldModuleProps = {
  mapseedField: MapseedDateFieldModule;
  setFieldValue: (key: string, date: any) => void;
} & FormikFieldProps &
  WithTranslation;

const moment = new MomentUtils();

// HACK: We use a far-future date to represent the notion of an "ongoing"
// date selection.
const ONGOING_DATE = moment.parse("9999-12-31", "YYYY-MM-DD");

const getDatepickerViews = formFormat =>
  (["year", "date", "month"] as DatePickerView[]).filter(view =>
    // Align the DatePicker's views with the passed date format string
    // (i.e. `YYYY MM`)
    formFormat.toLowerCase().includes(view[0]),
  );

const DateField = ({
  field: { name, value, onBlur, onChange },
  mapseedField: {
    key,
github AdExNetwork / adex-platform / src / components / dashboard / forms / items / Campaign / CampaignFinance.js View on Github external
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import NewCampaignHoc from './NewCampaignHoc'
import Translate from 'components/translate/Translate'
import Grid from '@material-ui/core/Grid'
import FormGroup from '@material-ui/core/FormGroup'
import FormControlLabel from '@material-ui/core/FormControlLabel'
import Checkbox from '@material-ui/core/Checkbox'
import Dropdown from 'components/common/dropdown'
import TextField from '@material-ui/core/TextField'
import DateTimePicker from 'components/common/DateTimePicker'
import { utils } from 'ethers'
import { validations } from 'adex-models'
import MomentUtils from '@date-io/moment'
import { totalFeesFormatted } from 'services/smart-contracts/actions/core'
const moment = new MomentUtils()

const VALIDATOR_LEADER_URL = process.env.VALIDATOR_LEADER_URL
const VALIDATOR_LEADER_ID = process.env.VALIDATOR_LEADER_ID
const VALIDATOR_LEADER_FEE = '0'
const VALIDATOR_FOLLOWER_URL = process.env.VALIDATOR_FOLLOWER_URL
const VALIDATOR_FOLLOWER_ID = process.env.VALIDATOR_FOLLOWER_ID
const VALIDATOR_FOLLOWER_FEE = '0'

const AdvPlatformValidators = {
	[VALIDATOR_LEADER_ID]: {
		id: VALIDATOR_LEADER_ID,
		url: VALIDATOR_LEADER_URL,
		fee: VALIDATOR_LEADER_FEE,
	},
}
github AdExNetwork / adex-platform / src / helpers / formatters.js View on Github external
import { formatUnits, commify } from 'ethers/utils'
import MomentUtils from '@date-io/moment'
const moment = new MomentUtils()

const DEFAULT_DATETIME_FORMAT = 'YYYY-MM-DD HH:mm'

export const formatDateTime = (timestamp, format = DEFAULT_DATETIME_FORMAT) => {
	if (!timestamp) {
		return 'no date'
	}
	const date = moment.date(timestamp)
	return date.format(format)
}

export const formatTokenAmount = (
	amountString,
	decimals = 18,
	pretty,
	toFixed

@date-io/moment

Abstraction over common javascript date management libraries

MIT
Latest version published 3 months ago

Package Health Score

80 / 100
Full package analysis

Popular @date-io/moment functions