How to use moment-range - 10 common examples

To help you get started, we’ve selected a few moment-range 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 resource-watch / resource-watch / components / widgets / editor / tooltip / FilterDateTooltip.js View on Github external
import PropTypes from 'prop-types';
import { toastr } from 'react-redux-toastr';
import Moment from 'moment';
import { extendMoment } from 'moment-range';

// Redux
import { connect } from 'react-redux';
import { toggleTooltip } from 'redactions/tooltip';

// Services
import DatasetService from 'components/widgets/editor/services/DatasetService';

// Components
import Button from 'components/widgets/editor/ui/Button';

const moment = extendMoment(Moment);

class FilterDateTooltip extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      values: []
    };

    // DatasetService
    this.datasetService = new DatasetService(props.datasetID, {
      apiURL: process.env.WRI_API_URL,
      language: props.locale
    });
  }
github appirio-tech / connect-app / src / projects / detail / components / PhaseCard / EditStageForm.jsx View on Github external
const TCFormFields = FormsyForm.Fields
// import enhanceDropdown from 'appirio-tech-react-components/components/Dropdown/enhanceDropdown'
import { updatePhase as updatePhaseAction, firePhaseDirty, firePhaseDirtyUndo } from '../../../actions/project'
import LoadingIndicator from '../../../../components/LoadingIndicator/LoadingIndicator'
import SelectDropdown from '../../../../components/SelectDropdown/SelectDropdown'
import { PHASE_STATUS_COMPLETED, PHASE_STATUS, PHASE_STATUS_ACTIVE, PHASE_STATUS_DRAFT } from '../../../../config/constants'
import Tooltip from 'appirio-tech-react-components/components/Tooltip/Tooltip'
import { TOOLTIP_DEFAULT_DELAY } from '../../../../config/constants'
import { getPhaseActualData } from '../../../../helpers/projectHelper'
import DeletePhase from './DeletePhase'
import {
  ROLE_CONNECT_ADMIN,
  ROLE_ADMINISTRATOR,
} from '../../../../config/constants'

const moment = extendMoment(Moment)
const phaseStatuses = PHASE_STATUS.map(ps => ({
  title: ps.name,
  value: ps.value,
}))

class EditStageForm extends React.Component {
  constructor(props) {
    super(props)

    this.state = {
      isUpdating: false,
      isEdittable: (_.get(props, 'phase.status') !== PHASE_STATUS_COMPLETED) || (_.get(props, 'isAdmin')),
      disableActiveStatusFields: _.get(props, 'phase.status') !== PHASE_STATUS_ACTIVE,
      showPhaseOverlapWarning: false,
      phaseIsdirty: false,
      showActivatingWarning: false,
github propertybase / react-lds / src / components / Datepicker / Datepicker.js View on Github external
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';

import Moment from 'moment-timezone';
// eslint-disable-next-line
import { extendMoment } from 'moment-range';

import { ClickOutside } from '../ClickOutside';
import { Input } from '../Form';
import { IconButton } from '../Button';

const moment = extendMoment(Moment);

const defaultDateFormat = 'l';
const placeholderDateFormat = 'L';
const iso8601DateFormat = 'YYYY-MM-DD';
const defaultTranslations = {
  inputFieldError: '',
  inputFieldLabel: 'Date',
  today: 'Today',
};

export class DatepickerRaw extends Component {
  /**
   * Renders visible weekdays
   * @return {ReactElement} thead
   */
  static renderWeekHeader() {
github freeCodeCamp / meeting-for-good / client / components / AvailabilityGrid / availabilityGridHoursTitle.js View on Github external
import Moment from 'moment';
import { extendMoment } from 'moment-range';
import cssModules from 'react-css-modules';
import React from 'react';
import PropTypes from 'prop-types';
import momentPropTypes from 'react-moment-proptypes';
import SettingsEthernet from 'material-ui/svg-icons/action/settings-ethernet';
import _ from 'lodash';
import styles from './availability-grid.css';

const moment = extendMoment(Moment);

// calculate the numbers of cells to offset the hours grid
// since we only want display the full hours
const initialOffSet = (allTimes) => {
  if (allTimes[0].minutes() !== 0) {
    return 4 - (allTimes[0].minutes() / 15);
  }
  return 0;
};

// depois
const cellForOffsetAfterjump = (jumpIndexAllTimes, allTimes) => {
  const nextfullHour = moment(allTimes[jumpIndexAllTimes]).startOf('hour').add(1, 'h');
  const numCells = nextfullHour.diff(moment(allTimes[jumpIndexAllTimes]), 'minutes') / 15;
  const cell = (numCells &lt; 4) ? <div style="{{"> : null;
  return cell;</div>
github hyperledger / cello / user-dashboard / src / routes / api / chain / index.js View on Github external
/* Copyright IBM Corp, All Rights Reserved.

 SPDX-License-Identifier: Apache-2.0
*/
import { Router } from 'express'
const Chain = require("../../../modules/chain");
import ChainModel from '../../../models/chain'
import ChainCode from '../../../models/chainCode'
import util from 'util'
import config from '../../../config'
import Moment from 'moment'
import { extendMoment } from 'moment-range';
const moment = extendMoment(Moment);
const log4js = require('log4js');
const logger = log4js.getLogger(__filename.slice(__dirname.length + 1));
const logLevel = process.env.DEV === "True" ? "DEBUG" : "INFO"
logger.setLevel(logLevel);

const router = new Router()

router.get("/:apikey/list", function(req, res) {
  const chain = new Chain(req.apikey, req.username);
  chain.list(req.query.page).then(function(result) {
    res.json({
      ...result,
      limit: config.limit.chainNumber
    });
  }).catch(function(err) {
    res.json(err);
github AdExNetwork / adex-platform / src / helpers / dev / auctionBidsStatsGenerator.js View on Github external
// Generate some random bids reports to use with charts until the AdEx node ready
import { Bid } from 'adex-models'
import Helper from 'helpers/miscHelpers'
import Moment from 'moment'
import { extendMoment } from 'moment-range'
const moment = extendMoment(Moment)

const AVAILABLE_SLOTS = 2000000 // 2 000 000
const BID_STEP_SLOTS = 10000 // 10 000 (Just for the random data)
const BID_PER_SLOT_AMOUNT_STEP = 1
const MIN_BID_PER_SLOT_AMOUNT = BID_PER_SLOT_AMOUNT_STEP * 5 // 5 cents
const TOTAL_BIDS = 10
const MAX_BID_PER_SLOT_AMOUNT = MIN_BID_PER_SLOT_AMOUNT * 20 // Just for the random data

class AuctionBidsGenerator {
	constructor() {
		this.auctionBids = this.generateSomeRandomAuctionBids()
	}

	generateSomeRandomAuctionBids() {
		let firstPoints = AVAILABLE_SLOTS
		let firstBidAmountPerSlot = MIN_BID_PER_SLOT_AMOUNT
github propertybase / react-lds / src / components / Datepicker / __tests__ / Datepicker.spec.js View on Github external
beforeEach(() => {
    moment = extendMoment(Moment);
    onChangeMock.mockClear();
  });
github brtjkzl / coypu / src / store / helpers.js View on Github external
export const weekDays = timeline => {
  const dayFormat = 'YYYY-MM-DD'
  const startOfWeek = timeline.startOf('week').format(dayFormat)
  const endOfWeek = timeline.endOf('week').format(dayFormat)
  const week = extendMoment(moment).range(startOfWeek, endOfWeek).by('days')

  return Array.from(week).map(day => day.format(dayFormat))
}
github hyperledger / cello / user-dashboard / src / modules / chain.js View on Github external
/**
 * Created by lixuc on 2017/5/3.
 */
var rp = require("request-promise");
var configuration = require("./configuration");
var dt = require("../kit/date-tool");
var Pagination = require("../kit/pagination");
import Moment from 'moment'
import { extendMoment } from 'moment-range';
import util from 'util'
import config from '../config'
import sleep from 'sleep-promise';
const crypto = require("crypto");
const mongoose = require('mongoose');
const moment = extendMoment(Moment);
const log4js = require('log4js');
const logger = log4js.getLogger(__filename.slice(__dirname.length + 1));
const logLevel = process.env.DEV === "True" ? "DEBUG" : "INFO"
import ChainModel from '../models/chain'
import ChainCode from '../models/chainCode'
logger.setLevel(logLevel);

function chain(apikey, username) {
    this.apikey = apikey;
    this.username = username;
}
chain.prototype = {
    RESTfulURL: "http://" + configuration.RESTful_Server + configuration.RESTful_BaseURL,
    PoolManagerURL: "http://" + configuration.PoolManager_Server + configuration.PoolManager_BaseURL,
    LogURL: "http://" + configuration.Log_Server + configuration.Log_BaseURL,
    amount: function() {
github Dennitz / Timetable / src / reducers / appointments.js View on Github external
import Moment from 'moment';
import {
  createSelector,
  createSelectorCreator,
  defaultMemoize,
} from 'reselect';
import { extendMoment } from 'moment-range';

import {
  ADD_APPOINTMENTS,
  REMOVE_APPOINTMENTS,
} from '../actions/appointment-actions';
import { REMOVE_COURSE } from '../actions/course-actions';
import { WEEKLY, BIWEEKLY } from '../lib/recurrence';

const moment = extendMoment(Moment);

export type AppointmentsPerDay = Array&gt;;

const INITITAL_STATE = {};

export default function reducer(
  state: AppointmentsState = INITITAL_STATE,
  action: Action,
) {
  switch (action.type) {
    case ADD_APPOINTMENTS:
      return {
        ...state,
        ...action.appointments,
      };
    case REMOVE_APPOINTMENTS:

moment-range

Fancy date ranges for Moment.js

Unlicense
Latest version published 6 years ago

Package Health Score

59 / 100
Full package analysis

Popular moment-range functions

Similar packages