How to use the luxon.DateTime.fromFormat function in luxon

To help you get started, we’ve selected a few luxon 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 flow-typed / flow-typed / definitions / npm / luxon_v0.4.x / flow_v0.104.x- / test_luxon.js View on Github external
// $ExpectError
DateTime.fromSQL();
// $ExpectError
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { foo: "bar" });
// $ExpectError
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { zone: 2 });
// $ExpectError
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { locale: 2 });
// $ExpectError
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { setZone: "yes" });
// $ExpectError
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { outputCalendar: 2 });
// $ExpectError
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { numberingSystem: 2 });

var date: DateTime = DateTime.fromFormat(
  '12/15/2017, 12:47:25 PM',
  'dd/MM/yyyy h:mm:ss a'
);
DateTime.fromFormat('12/15/2017, 12:47:25 PM', 'dd/MM/yyyy h:mm:ss a', {});
DateTime.fromFormat('12/15/2017, 12:47:25 PM', 'dd/MM/yyyy h:mm:ss a', {
  zone: 'America/Chicago',
});
DateTime.fromFormat('12/15/2017, 12:47:25 PM', 'dd/MM/yyyy h:mm:ss a', {
  zone: new CustomZone(),
});
DateTime.fromFormat('12/15/2017, 12:47:25 PM', 'dd/MM/yyyy h:mm:ss a', {
  locale: 'en-US',
});
DateTime.fromFormat('12/15/2017, 12:47:25 PM', 'dd/MM/yyyy h:mm:ss a', {
  zone: 'America/Chicago',
  setZone: true,
github CalendarioFX / Calendario / src / lib / events.ts View on Github external
function processEvent (
    dwd: string | number, event: CalendarioEvent, date: 
    DateTime, data: ProcessedCalendarioEvents, options: CalendarioOptions
): ProcessedCalendarioEvents {
    if (!data[dwd]) {
        data[dwd] = []
    }

    let repeater: string

    const _edt = event.repeat ? 
        (event.endDate ? DateTime.fromFormat(event.endDate, options.format, {locale: options.parserLocale}) 
            : date.plus({ years: 100 }) ) : date

    if (!event.repeat) repeater = 'SINGLE'
    else if (event.repeat === 'YEARLY' || event.repeat === 'MONTHLY') repeater = event.repeat
    else if (event.repeat.split(/[,\s]+/).length < 7) repeater = 'WEEKLY'
    else if (event.repeat.split(/[,\s]+/).length === 7) repeater = 'INTERVAL'

    data[dwd].push({
        ...event,
        ...{
            dates: [date.startOf('day'), _edt.startOf('day')],
            generator: repeaters[repeater]
        }
    })

    return data
github orgapp / orgajs / packages / orga / src / timestamp.js View on Github external
const _parseDate = (date, time) => {
    let text = date
    let format = `yyyy-MM-dd`
    if (time) {
      text += ` ${time}`
      format += ` HH:mm`
    }
    return DateTime.fromFormat(text, format, { zone: timezone }).toJSDate()
  }
github cjdev / visual-stack / packages / visual-stack / src / components / DatePicker / index.js View on Github external
function fromInternalDateFormat(date) {
  return DateTime.fromFormat(date, internalDateFormat).toLocal();
}
github softwerkskammer / Agora / softwerkskammer / lib / wiki / wikiObjects.js View on Github external
  date() {return DateTime.fromFormat(this.datestring || '', 'yyyy-M-d');}
github cjdev / visual-stack / packages / visual-stack-docs / src / containers / Components / Docs / datepicker.js View on Github external
previousCalendarRanges => {
              const [baseStart, baseEnd] = previousCalendarRanges[0];
              return [
                DateTime.fromFormat(baseStart, 'yyyy-MM-dd')
                  .minus({ years: 1 })
                  .toFormat('yyyy-MM-dd'),
                DateTime.fromFormat(baseEnd, 'yyyy-MM-dd')
                  .minus({ years: 1 })
                  .toFormat('yyyy-MM-dd'),
              ];
            }
          ),
github dmtrKovalenko / date-io / packages / luxon / src / luxon-utils.ts View on Github external
public parse(value: string, formatString: string) {
    if (value === "") {
      return null;
    }

    return DateTime.fromFormat(value, formatString);
  }
github 8base / boost / src / components / DateInput / DateInput.utils.js View on Github external
export const fromViewFormatToLuxon = (value: ?string, dateFormat: ?string) => {
  if (value) {
    value = DateTime.fromFormat(value, dateFormat || DATE_FORMAT);
  } else {
    value = null;
  }

  return value;
};