luxon#Info JavaScript Examples

The following examples show how to use luxon#Info. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: calendar.js    From jc-calendar with MIT License 6 votes vote down vote up
/**
 * Returns long, short, and narrow weekdays descriptions for the current `APP_LOCALE`.
 */
export function getWeekdaysDescriptions() {
  const config = { locale: APP_LOCALE };
  const long = Info.weekdaysFormat('long', config);
  const short = Info.weekdaysFormat('short', config);
  const narrow = Info.weekdaysFormat('narrow', config);

  const weekDays = Array(DAYS_IN_A_WEEK)
    .fill(null)
    .map((_, weekDayIndex) => {
      return {
        long: long[weekDayIndex],
        short: short[weekDayIndex],
        narrow: narrow[weekDayIndex],
      };
    });

  // luxon only return ISO weekdays order,
  // and we want Sunday to be the first day.
  return [
    weekDays[DAYS_IN_A_WEEK - 1],
    ...weekDays.slice(0, DAYS_IN_A_WEEK - 1),
  ];
}