How to use the fecha.i18n function in fecha

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 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 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 akveo / react-native-ui-kitten / src / components / ui / calendar / service / nativeDate.service.ts View on Github external
private getFechaMonthNames(style: TranslationWidth): string[] {
    switch (style) {
      case TranslationWidth.SHORT:
        return fecha.i18n.monthNamesShort;
      case TranslationWidth.LONG:
        return fecha.i18n.monthNames;
    }
  }
github akveo / react-native-ui-kitten / src / components / ui / calendar / service / nativeDate.service.ts View on Github external
private getFechaMonthNames(style: TranslationWidth): string[] {
    switch (style) {
      case TranslationWidth.SHORT:
        return fecha.i18n.monthNamesShort;
      case TranslationWidth.LONG:
        return fecha.i18n.monthNames;
    }
  }
github akveo / react-native-ui-kitten / src / components / ui / calendar / service / nativeDate.service.ts View on Github external
private setFechaLocaleData(config: I18nConfig) {
    fecha.i18n.dayNames = config.dayNames[TranslationWidth.LONG];
    fecha.i18n.dayNamesShort = config.dayNames[TranslationWidth.SHORT];
    fecha.i18n.monthNames = config.monthNames[TranslationWidth.LONG];
    fecha.i18n.monthNamesShort = config.monthNames[TranslationWidth.SHORT];
  }
}
github akveo / react-native-ui-kitten / src / components / ui / calendar / service / nativeDate.service.ts View on Github external
private setFechaLocaleData(config: I18nConfig) {
    fecha.i18n.dayNames = config.dayNames[TranslationWidth.LONG];
    fecha.i18n.dayNamesShort = config.dayNames[TranslationWidth.SHORT];
    fecha.i18n.monthNames = config.monthNames[TranslationWidth.LONG];
    fecha.i18n.monthNamesShort = config.monthNames[TranslationWidth.SHORT];
  }
}
github akveo / react-native-ui-kitten / src / components / ui / calendar / service / nativeDate.service.ts View on Github external
private setFechaLocaleData(config: I18nConfig) {
    fecha.i18n.dayNames = config.dayNames[TranslationWidth.LONG];
    fecha.i18n.dayNamesShort = config.dayNames[TranslationWidth.SHORT];
    fecha.i18n.monthNames = config.monthNames[TranslationWidth.LONG];
    fecha.i18n.monthNamesShort = config.monthNames[TranslationWidth.SHORT];
  }
}
github akveo / react-native-ui-kitten / src / components / ui / calendar / service / nativeDate.service.ts View on Github external
private setFechaLocaleData(config: I18nConfig) {
    fecha.i18n.dayNames = config.dayNames[TranslationWidth.LONG];
    fecha.i18n.dayNamesShort = config.dayNames[TranslationWidth.SHORT];
    fecha.i18n.monthNames = config.monthNames[TranslationWidth.LONG];
    fecha.i18n.monthNamesShort = config.monthNames[TranslationWidth.SHORT];
  }
}

fecha

Date formatting and parsing

MIT
Latest version published 3 years ago

Package Health Score

76 / 100
Full package analysis