How to use the luxon.DateTime.fromRFC2822 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
DateTime.fromMillis(123412323, { numberingSystem: 2 });

var date: DateTime = DateTime.fromRFC2822("12/15/2017, 12:47:25 PM");
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", {});
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: "America/Chicago" });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: new CustomZone() });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { locale: "en-US" });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", {
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromRFC2822();
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { foo: "bar" });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: 2 });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { locale: 2 });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { setZone: "yes" });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { outputCalendar: 2 });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { numberingSystem: 2 });

var date: DateTime = DateTime.fromSQL("12/15/2017, 12:47:25 PM");
DateTime.fromSQL("12/15/2017, 12:47:25 PM", {});
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { zone: "America/Chicago" });
github flow-typed / flow-typed / definitions / npm / luxon_v0.2.x / flow_v0.104.x- / test_luxon.js View on Github external
numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromRFC2822();
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { foo: "bar" });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: 2 });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { locale: 2 });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { setZone: "yes" });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { outputCalendar: 2 });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { numberingSystem: 2 });

var date: DateTime = DateTime.fromSQL("12/15/2017, 12:47:25 PM");
DateTime.fromSQL("12/15/2017, 12:47:25 PM", {});
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { zone: "America/Chicago" });
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { zone: new CustomZone() });
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { locale: "en-US" });
DateTime.fromSQL("12/15/2017, 12:47:25 PM", {
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromSQL();
// $ExpectError
github flow-typed / flow-typed / definitions / npm / luxon_v0.4.x / flow_v0.104.x- / test_luxon.js View on Github external
// $ExpectError
DateTime.fromMillis("1234234123");
// $ExpectError
DateTime.fromMillis(123412323, { foo: "bar" });
// $ExpectError
DateTime.fromMillis(123412323, { zone: 2 });
// $ExpectError
DateTime.fromMillis(123412323, { locale: 2 });
// $ExpectError
DateTime.fromMillis(123412323, { setZone: "yes" });
// $ExpectError
DateTime.fromMillis(123412323, { outputCalendar: 2 });
// $ExpectError
DateTime.fromMillis(123412323, { numberingSystem: 2 });

var date: DateTime = DateTime.fromRFC2822("12/15/2017, 12:47:25 PM");
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", {});
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: "America/Chicago" });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: new CustomZone() });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { locale: "en-US" });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", {
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromRFC2822();
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { foo: "bar" });
// $ExpectError
github flow-typed / flow-typed / definitions / npm / luxon_v1.x.x / flow_v0.104.x- / test_luxon.js View on Github external
// $ExpectError
DateTime.fromSeconds("1234234123");
// $ExpectError
DateTime.fromSeconds(123412323, { foo: "bar" });
// $ExpectError
DateTime.fromSeconds(123412323, { zone: 2 });
// $ExpectError
DateTime.fromSeconds(123412323, { locale: 2 });
// $ExpectError
DateTime.fromSeconds(123412323, { setZone: "yes" });
// $ExpectError
DateTime.fromSeconds(123412323, { outputCalendar: 2 });
// $ExpectError
DateTime.fromSeconds(123412323, { numberingSystem: 2 });

var date: DateTime = DateTime.fromRFC2822("12/15/2017, 12:47:25 PM");
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", {});
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: "America/Chicago" });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: new CustomZone() });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { locale: "en-US" });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", {
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromRFC2822();
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { foo: "bar" });
// $ExpectError
github flow-typed / flow-typed / definitions / npm / luxon_v0.4.x / flow_v0.104.x- / test_luxon.js View on Github external
numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromRFC2822();
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { foo: "bar" });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: 2 });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { locale: 2 });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { setZone: "yes" });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { outputCalendar: 2 });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { numberingSystem: 2 });

var date: DateTime = DateTime.fromSQL("12/15/2017, 12:47:25 PM");
DateTime.fromSQL("12/15/2017, 12:47:25 PM", {});
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { zone: "America/Chicago" });
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { zone: new CustomZone() });
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { locale: "en-US" });
DateTime.fromSQL("12/15/2017, 12:47:25 PM", {
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromSQL();
// $ExpectError
github DefinitelyTyped / DefinitelyTyped / types / luxon / luxon-tests.ts View on Github external
const dtHebrew = DateTime.local().reconfigure({ outputCalendar: 'hebrew' });
dtHebrew.outputCalendar; // $ExpectType string
dtHebrew.toLocaleString(); // $ExpectType string

DateTime.fromObject({ outputCalendar: 'buddhist' }).toLocaleString(DateTime.DATE_FULL);
Settings.defaultOutputCalendar = 'persian';

/* Formatting */
DateTime.fromISO('2014-08-06T13:07:04.054').toFormat('yyyy LLL dd'); // $ExpectType string

/* Parsing */
DateTime.fromObject({ zone: 'America/Los_Angeles' }); // $ExpectType DateTime
DateTime.fromISO('2016-05-25'); // $ExpectType DateTime
DateTime.fromJSDate(new Date()); // $ExpectType DateTime
DateTime.fromRFC2822('Tue, 01 Nov 2016 13:23:12 +0630'); // $ExpectType DateTime
DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT'); // $ExpectType DateTime
DateTime.fromSQL('2017-05-15 09:24:15'); // $ExpectType DateTime
DateTime.fromMillis(1542674993410); // $ExpectType DateTime
DateTime.fromSeconds(1542674993); // $ExpectType DateTime
DateTime.fromFormat('May 25 1982', 'LLLL dd yyyy'); // $ExpectType DateTime
DateTime.fromFormat('mai 25 1982', 'LLLL dd yyyy', { locale: 'fr' }); // $ExpectType DateTime

DateTime.fromFormatExplain('Aug 6 1982', 'MMMM d yyyy').regex;

/* Math */
const d1: DateTime = DateTime.local(2017, 2, 13).plus({ days: 30 });
const d2: DateTime = DateTime.fromISO('2017-04-30')
    .plus({ days: 1 })
    .plus({ months: 1 });

if (d1 < d2 || +d1 === +d2) {
github flow-typed / flow-typed / definitions / npm / luxon_v1.x.x / flow_v0.104.x- / test_luxon.js View on Github external
// $ExpectError
DateTime.fromSeconds(123412323, { foo: "bar" });
// $ExpectError
DateTime.fromSeconds(123412323, { zone: 2 });
// $ExpectError
DateTime.fromSeconds(123412323, { locale: 2 });
// $ExpectError
DateTime.fromSeconds(123412323, { setZone: "yes" });
// $ExpectError
DateTime.fromSeconds(123412323, { outputCalendar: 2 });
// $ExpectError
DateTime.fromSeconds(123412323, { numberingSystem: 2 });

var date: DateTime = DateTime.fromRFC2822("12/15/2017, 12:47:25 PM");
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", {});
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: "America/Chicago" });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: new CustomZone() });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { locale: "en-US" });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", {
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromRFC2822();
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { foo: "bar" });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: 2 });
// $ExpectError
github flow-typed / flow-typed / definitions / npm / luxon_v0.2.x / flow_v0.104.x- / test_luxon.js View on Github external
DateTime.fromMillis(123412323, { numberingSystem: 2 });

var date: DateTime = DateTime.fromRFC2822("12/15/2017, 12:47:25 PM");
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", {});
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: "America/Chicago" });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: new CustomZone() });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { locale: "en-US" });
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", {
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromRFC2822();
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { foo: "bar" });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: 2 });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { locale: 2 });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { setZone: "yes" });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { outputCalendar: 2 });
// $ExpectError
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { numberingSystem: 2 });

var date: DateTime = DateTime.fromSQL("12/15/2017, 12:47:25 PM");
DateTime.fromSQL("12/15/2017, 12:47:25 PM", {});
DateTime.fromSQL("12/15/2017, 12:47:25 PM", { zone: "America/Chicago" });
github NightlyCommit / twing / src / lib / extension / core / functions / date.ts View on Github external
}

        let parsedUtcOffset = 0;

        if (!date) {
            result = DateTime.local();
        } else if (date instanceof Date) {
            result = DateTime.fromJSDate(date);
        } else if (typeof date === 'string') {
            if (date === 'now') {
                result = DateTime.local();
            } else {
                result = DateTime.fromISO(date, {setZone: true});

                if (!result.isValid) {
                    result = DateTime.fromRFC2822(date, {setZone: true});
                }

                if (!result.isValid) {
                    result = DateTime.fromSQL(date, {setZone: true});
                }

                if (result.isValid) {
                    parsedUtcOffset = result.offset;
                } else {
                    result = modifyDate(date);
                }
            }
        } else if (typeof date === 'number') {
            // date is PHP timestamp - i.e. in seconds
            let ts = date as number * 1000;
github casbloem / vue-luxon / vue-luxon.js View on Github external
zone: sz
          });
        case "iso":
          return DateTime.fromISO(a, {
            zone: sz
          });
        case "http":
          return DateTime.fromHTTP(a, {
            zone: sz
          });
        case "jsdate":
          return DateTime.fromJSDate(a, {
            zone: sz
          });
        case "rfc2822":
          return DateTime.fromRFC2822(a, {
            zone: sz
          });
        default:
          return DateTime.fromFormat(a, sf, {
            zone: sz
          });
      }
    };