How to use fecha - 10 common examples

To help you get started, we’ve selected a few fecha 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 knacksteem / knacksteem.org / src / containers / Profile / index.js View on Github external
remoteUserObject,
      rewardFundObject,
      dynamicGlobalPropertiesObject,
      currentMedianHistoryPriceObject
    ]);


    const activeCategory = queryString.parse(this.props.location.search).category;
    const articlesList = typeof activeCategory !== 'undefined' ?
      articles.data.filter(article => article.category === activeCategory) : 
      articles.data;

    // If we've loaded all core objects...
    if (hasLoadedRemoteUserObject) {
      signupDate = fecha.format(
        fecha.parse(
          remoteUserObject.created.split('T')[0],
          'YYYY-MM-DD'
        ),
        'D MMMM YYYY'
      );

      if (typeof remoteUserObject === 'object'
      && Object.keys(remoteUserObject).length > 0) {
         console.log();
        if(remoteUserObject.json_metadata !== '' && Object.keys(JSON.parse(remoteUserObject.json_metadata)).length > 0 ){
          remoteUserObjectMeta = JSON.parse(remoteUserObject.json_metadata).profile
          coverImage = remoteUserObjectMeta.cover_image;
        }
        name = remoteUserObject.name;
        displayName = name && name !== '' ? name : uppercaseFirst(match.params.username);
        reputation = repLog10(parseFloat(remoteUserObject.reputation));
github 3846masa / lit-date / benchmarks / src / advanced.bench.js View on Github external
import { DateTime } from 'luxon';
import fecha from 'fecha';
import { format as dateFnsFormat } from 'date-fns';
import dateFnsLocaleJa from 'date-fns/locale/ja';
import dateformat from 'dateformat';
import litdate from 'lit-date';

const date = new Date('2000-01-06T12:34:56.789Z');
const expected = '1月6日(木)';

// Prepare
const dayOfWeekToName = ({ dayOfWeek }) => ['日', '月', '火', '水', '木', '金', '土'][dayOfWeek];
Object.assign(dateformat.i18n, {
  dayNames: ['日', '月', '火', '水', '木', '金', '土'],
});
Object.assign(fecha.i18n, {
  dayNamesShort: ['日', '月', '火', '水', '木', '金', '土'],
});

suite('Advanced usage', () => {
  benchmark('moment', () => {
    const actual = moment(date)
      .locale('ja')
      .format('M月D日(ddd)');
    console.assert(actual === expected);
  });
  benchmark('luxon', () => {
    const actual = DateTime.fromJSDate(date)
      .setLocale('ja')
      .toFormat('M月d日(ccc)');
    console.assert(actual === expected);
  });
github amazeui / amazeui-react / src / DateTimePicker / DatePicker.js View on Github external
var selectedDate = this.props.selectedDate;

    var currentDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), selectedDate.getDate(), 0, 0, 0, 0).valueOf();

    var prevMonth = new Date(year, month - 1, 28, 0, 0, 0, 0);
    var day = dateUtils.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());

    prevMonth.setDate(day);
    prevMonth.setDate(day - (prevMonth.getDay() - weekStart + 7) % 7);

    var nextMonth = new Date(prevMonth);

    nextMonth.setDate(nextMonth.getDate() + 42);
    nextMonth = nextMonth.valueOf();

    var minDate = this.props.minDate && fecha.parse(this.props.minDate, this.props.format);
    var maxDate = this.props.maxDate && fecha.parse(this.props.maxDate, this.props.format);

    while (prevMonth.valueOf() < nextMonth) {
      classes[this.prefixClass('day')] = true;

      prevY = prevMonth.getFullYear();
      prevM = prevMonth.getMonth();


      // set className old new
      if ((prevM < month && prevY === year) || prevY < year) {
        classes[this.prefixClass('old')] = true;
      } else if ((prevM > month && prevY === year) || prevY > year) {
        classes[this.prefixClass('new')] = true;
      }
github krystalcampioni / vue-hotel-datepicker / src / vendor / hotel-datepicker.js View on Github external
parseDate(date, format = this.format) {
        // Parse a date object
        return fecha.parse(date, format);
    }
github krystalcampioni / vue-hotel-datepicker / src / components / DatePicker.vue View on Github external
beforeMount() {
      fecha.i18n = {
        dayNames: this.i18n['day-names'],
        dayNamesShort: this.shortenString(this.i18n['day-names'], 3),
        monthNames: this.i18n['month-names'],
        monthNamesShort: this.shortenString(this.i18n['month-names'], 3),
        amPm: ['am', 'pm'],
        // D is the day of the month, function returns something like...  3rd or 11th
        DoFn: function (D) {
          return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10];
        }
      };
        if(this.checkIn &&
        (this.getMonthDiff(this.getNextMonth(new Date(this.startDate)), this.checkIn) > 0 ||
        this.getMonthDiff(this.startDate, this.checkIn) > 0)){
          this.createMonth(new Date(this.startDate));
          const count = this.getMonthDiff(this.startDate, this.checkIn)
          let nextMonth = new Date(this.startDate)
github home-assistant / home-assistant-polymer / js / util.js View on Github external
import computeStateDisplay from './common/entity/compute_state_display.js';
import computeStateName from './common/entity/compute_state_name.js';
import coverIcon from './common/entity/cover_icon.js';
import domainIcon from './common/entity/domain_icon.js';
import featureClassNames from './common/entity/feature_class_names.js';
import sensorIcon from './common/entity/sensor_icon.js';
import sortByName from './common/entity/states_sort_by_name.js';
import stateCardType from './common/entity/state_card_type.js';
import stateIcon from './common/entity/state_icon.js';
import stateMoreInfoType from './common/entity/state_more_info_type.js';
import timerTimeRemaining from './common/entity/timer_time_remaining.js';

const language = navigator.languages ?
  navigator.languages[0] : navigator.language || navigator.userLanguage;

fecha.masks.haDateTime = `${fecha.masks.shortTime} ${fecha.masks.mediumDate}`;

window.hassUtil = {
  // const
  DEFAULT_ICON: DEFAULT_DOMAIN_ICON,
  OFF_STATES: STATES_OFF,
  DOMAINS_WITH_NO_HISTORY: DOMAINS_MORE_INFO_NO_HISTORY,

  // config
  computeLocationName,
  isComponentLoaded,

  // datetime
  durationToSeconds,
  formatDate: dateObj => formatDate(dateObj, language),
  formatDateTime: dateObj => formatDateTime(dateObj, language),
  formatTime: dateObj => formatTime(dateObj, language),
github antvis / F2 / test / unit / scale / cat-spec.js View on Github external
it('getTicks()', function() {
    const ticks = scale.getTicks();
    expect(typeof ticks[0]).to.be.equal('object');
    expect(ticks[1].value).to.be.equal(0.5);
    expect(ticks[1].text).to.be.equal(fecha.format(1442937600000, mask));
  });
github lpreterite / datagent / test / schema.js View on Github external
return val => {
            if (typeof val === 'string') return val;
            if (typeof val === "number") val = new Date(val);
            return fecha.format(val, format);
        }
    }
github ruiyong-lee / weapp-vue-eggjs-shop-demo / mobile_uni-app / src / common / util.js View on Github external
formatToDayTime(date = new Date()) {
    return fecha.format(date, 'YYYY-MM-DD HH:mm:ss');
  },
  formatDayStrToDayTimeStr(dateStr) {
github OpusCapita / filemanager / packages / connector-google-drive-v2 / src / list-view-layout.js View on Github external
function formatDate(
  viewLayoutOptions, { cellData, columnData, columnIndex, dataKey, isScrolling, rowData, rowIndex }
) {
  if (cellData) {
    const { dateTimePattern } = viewLayoutOptions;
    return fecha.format(new Date().setTime(cellData), dateTimePattern);
  }

  return '';
}

fecha

Date formatting and parsing

MIT
Latest version published 2 years ago

Package Health Score

76 / 100
Full package analysis