Esempio n. 1
0
  constructor(props) {
    super(props);

    const {
      data: { me, movie },
      movieId
    } = props;

    let date = now;

    if (isAfter(movie.releaseDate, now)) {
      date = new Date(movie.releaseDate);
    }

    this.state = {
      showing: {
        date,
        time: format(now, "HH:mm"),
        location: "",
        sfScreen: null,
        movieId: movieId,
        admin: me.id
      },
      selectedDate: formatYMD(date)
    };
  }
  parseSelectedDate(selectedDate) {
    if (selectedDate) {
      selectedDate = parse(selectedDate);

      // Selected Date should not be before min date or after max date
      if (isBefore(selectedDate, this._minDate)) {
        return this._minDate;
      } else if (isAfter(selectedDate, this._maxDate)) {
        return this._maxDate;
      }
    }

    return startOfDay(new Date(selectedDate));
  }
Esempio n. 3
0
export const tokenRefresh = setContext(async (req, { headers }) => {
  const expiresAt = new Date(getExpiresAt() || 0);

  const nowPlusSafeTime = addMinutes(new Date(), 5);

  if (isAfter(nowPlusSafeTime, expiresAt)) {
    const auth = window.gapi.auth2.getAuthInstance();
    const response = await auth.currentUser.get().reloadAuthResponse();
    setUserInfo(response);

    console.log("Refreshed token!");
  }

  // else reuse token!
});
Esempio n. 4
0
function ArchiveForecastRoute({ name, date }) {
    if (date && isAfter(parse(date), endOfYesterday())) {
        return <Redirect to={`/forecasts/${name}`} />
    }

    if (name && date) {
        open(name, date)
    }

    return (
        <ArchiveForecast
            name={name}
            date={utils.parseDate(date)}
            onParamsChange={handleParamsChange}
        />
    )
}
Esempio n. 5
0
const getSelectedGameIndexFromQueryParams = (params = {}) => {
  const year = getYearFromQueryParams(params);

  const selectedGameIndex = Number(params.selectedGameIndex);

  // Numeric selected game index is provided.
  if (!isNaN(selectedGameIndex)) {
    if (selectedGameIndex <= 0 || selectedGameIndex > schedule[year].length) {
      // If the selected game index is invalid for this year, use the default selected game index.
      return DEFAULT_SELECTED_GAME_INDEX;
    } else {
      // Otherwise, subtract one from the selected game index in the URL since they are 1-based, not
      // 0-based.
      return selectedGameIndex - 1;
    }
  }

  // No selected game index or a non-numeric game index is provided.
  if (year !== DEFAULT_YEAR) {
    // If the year is not the default year, show the default game index.
    return DEFAULT_SELECTED_GAME_INDEX;
  } else {
    // Otherwise, show the latest completed or next upcoming game.
    const gamesPlayedCount = _.filter(schedule[year], (game) => game.result).length;
    if (gamesPlayedCount === 0) {
      // If no games have been played yet, select the default game index.
      return DEFAULT_SELECTED_GAME_INDEX;
    } else if (gamesPlayedCount === schedule[year].length) {
      // If all games have already played, select the last game.
      return schedule[year].length - 1;
    } else {
      // Otherwise, select the latest completed game until the Wednesday before the next game, at
      // which point, select the next game.
      // TODO: remove date or fullDate once these are all standardized.
      const nextCompletedGameDate =
        schedule[year][gamesPlayedCount].date || schedule[year][gamesPlayedCount].fullDate;
      const wednesdayBeforeNextGameDate = subDays(new Date(nextCompletedGameDate), 4);
      if (isAfter(new Date(), wednesdayBeforeNextGameDate)) {
        return gamesPlayedCount;
      } else {
        return gamesPlayedCount - 1;
      }
    }
  }
};
Esempio n. 6
0
const validate = (values, props) => {
  const { formatMessage } = props.intl;

  const errors = {};
  if (!values.amount) {
    errors.amount = formatMessage(messages.requiredField);
  } else if (!validator.isDecimal(`${values.amount}`)) {
    errors.amount = formatMessage(messages.mustBeValidNumber);
  } else if (values.amount < 0) {
    errors.amount = formatMessage(messages.mustBeValidNumber);
  }

  if (!values.description) {
    errors.description = formatMessage(messages.requiredField);
  }

  if (!values.variableSymbol) {
    errors.variableSymbol = formatMessage(messages.requiredField);
  } else if (!validator.isDecimal(`${values.variableSymbol}`)) {
    errors.variableSymbol = formatMessage(messages.mustBeValidNumber);
  }

  if (!values.validFrom) {
    errors.validFrom = formatMessage(messages.requiredField);
  } else if (values.deadlineAt && isAfter(values.validFrom, values.deadlineAt)) {
    errors.validFrom = formatMessage(messages.validFromDateMustBeBeforeDeadlineDate);
  }

  if (!values.deadlineAt) {
    errors.deadlineAt = formatMessage(messages.requiredField);
  }

  if (!props.userGroup || props.userGroup.users.size < 1) {
    errors._error = formatMessage(messages.selectAtLeastOneUser);
  }

  if (!values.transactionType || (values.transactionType !== 'kredit' && values.transactionType !== 'debet')) {
    errors.transactionType = formatMessage(messages.requiredField);
  }

  

  return errors;
};
Esempio n. 7
0
      produits.filter(produit => {
        if (
          !produit.enStock ||
          !fournisseursIds[produit.fournisseurId].visible
        ) {
          return false;
        }

        const limitationFournisseur = commande.datesLimites.find(
          dL => dL.fournisseurId === produit.fournisseurId
        );

        if (!limitationFournisseur) return true;

        return (
          limitationFournisseur.dateLimite === null ||
          !isAfter(new Date(), limitationFournisseur.dateLimite)
        );
        return false;
      })
Esempio n. 8
0
export const isAfter = (date, dateBounds) => {
    const endingDate = Math.max(...dateBounds);

    // @TODO: remove the `new Date()` constructor in the next major version: we need to force it at configuration level.
    return dateIsAfter(new Date(date), endingDate);
};
Esempio n. 9
0
 const firstStream = streams.sort((a, b) => isAfter(a.get('eventStartDateTime'), b.get('eventStartDateTime')) ? 1 : -1).first();
Esempio n. 10
0
 AccessToken.prototype.expired = function expired() {
   return isAfter(new Date(), this.token.expires_at);
 };
Esempio n. 11
0
			if (vTeamData.passOffenseRank) vTeam.pass_offense = parseInt(vTeamData.passOffenseRank, 10);

			if (vTeamData.rushDefenseRank) vTeam.rush_defense = parseInt(vTeamData.rushDefenseRank, 10);

			if (vTeamData.rushOffenseRank) vTeam.rush_offense = parseInt(vTeamData.rushOffenseRank, 10);

			if (!vTeam.bye_week || vTeam.bye_week === w) vTeam.bye_week = w + 1;

			vTeam.save();
		});
	},

	updateGames () {
		const week = currentWeek.call();
		const firstGameOfWeek = getFirstGameOfWeek.call({ week }, handleError);
		const weekHasStarted = isAfter(firstGameOfWeek.kickoff, new Date());
		const weekToUpdate = (weekHasStarted ? week + 1 : week);
		const games = this.getGamesForWeek(weekToUpdate);

		console.log(`Updating game info for week ${weekToUpdate}...`);

		games.forEach(gameObj => {
			/**
			 * @typedef {Object} teamData
			 * @property {string} id
			 * @property {string} spread
			 * @property {string} passDefenseRank
			 * @property {string} passOffenseRank
			 * @property {string} rushDefenseRank
			 * @property {string} rushOffenseRank
			 */
Esempio n. 12
0
 .filter((game) => { return isAfter(game.date, now); })