public/libraries.js
function configFromRFC2822(config) {
    var string, match, dayFormat,
        dateFormat, timeFormat, tzFormat;
    var timezones = {
        ' GMT': ' +0000',
        ' EDT': ' -0400',
        ' EST': ' -0500',
        ' CDT': ' -0500',
        ' CST': ' -0600',
        ' MDT': ' -0600',
        ' MST': ' -0700',
        ' PDT': ' -0700',
        ' PST': ' -0800'
    };
    var military = 'YXWVUTSRQPONZABCDEFGHIKLM';
    var timezone, timezoneIndex;

    string = config._i
        .replace(/\([^\)]*\)|[\n\t]/g, ' ') // Remove comments and folding whitespace
        .replace(/(\s\s+)/g, ' ') // Replace multiple-spaces with a single space
        .replace(/^\s|\s$/g, ''); // Remove leading and trailing spaces
    match = basicRfcRegex.exec(string);

    if (match) {
        dayFormat = match[1] ? 'ddd' + ((match[1].length === 5) ? ', ' : ' ') : '';
        dateFormat = 'D MMM ' + ((match[2].length > 10) ? 'YYYY ' : 'YY ');
        timeFormat = 'HH:mm' + (match[4] ? ':ss' : '');

        // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
        if (match[1]) { // day of week given
            var momentDate = new Date(match[2]);
            var momentDay = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][momentDate.getDay()];

            if (match[1].substr(0,3) !== momentDay) {
                getParsingFlags(config).weekdayMismatch = true;
                config._isValid = false;
                return;
            }
        }

        switch (match[5].length) {
            case 2: // military
                if (timezoneIndex === 0) {
                    timezone = ' +0000';
                } else {
                    timezoneIndex = military.indexOf(match[5][1].toUpperCase()) - 12;
                    timezone = ((timezoneIndex < 0) ? ' -' : ' +') +
                        (('' + timezoneIndex).replace(/^-?/, '0')).match(/..$/)[0] + '00';
                }
                break;
            case 4: // Zone
                timezone = timezones[match[5]];
                break;
            default: // UT or +/-9999
                timezone = timezones[' GMT'];
        }
        match[5] = timezone;
        config._i = match.splice(1).join('');
        tzFormat = ' ZZ';
        config._f = dayFormat + dateFormat + timeFormat + tzFormat;
        configFromStringAndFormat(config);
        getParsingFlags(config).rfc2822 = true;
    } else {
        config._isValid = false;
    }
}
function configFromRFC2822(config) {
    var string, match, dayFormat,
        dateFormat, timeFormat, tzFormat;
    var timezones = {
        ' GMT': ' +0000',
        ' EDT': ' -0400',
        ' EST': ' -0500',
        ' CDT': ' -0500',
        ' CST': ' -0600',
        ' MDT': ' -0600',
        ' MST': ' -0700',
        ' PDT': ' -0700',
        ' PST': ' -0800'
    };
    var military = 'YXWVUTSRQPONZABCDEFGHIKLM';
    var timezone, timezoneIndex;

    string = config._i
        .replace(/\([^\)]*\)|[\n\t]/g, ' ') // Remove comments and folding whitespace
        .replace(/(\s\s+)/g, ' ') // Replace multiple-spaces with a single space
        .replace(/^\s|\s$/g, ''); // Remove leading and trailing spaces
    match = basicRfcRegex.exec(string);

    if (match) {
        dayFormat = match[1] ? 'ddd' + ((match[1].length === 5) ? ', ' : ' ') : '';
        dateFormat = 'D MMM ' + ((match[2].length > 10) ? 'YYYY ' : 'YY ');
        timeFormat = 'HH:mm' + (match[4] ? ':ss' : '');

        // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
        if (match[1]) { // day of week given
            var momentDate = new Date(match[2]);
            var momentDay = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][momentDate.getDay()];

            if (match[1].substr(0,3) !== momentDay) {
                getParsingFlags(config).weekdayMismatch = true;
                config._isValid = false;
                return;
            }
        }

        switch (match[5].length) {
            case 2: // military
                if (timezoneIndex === 0) {
                    timezone = ' +0000';
                } else {
                    timezoneIndex = military.indexOf(match[5][1].toUpperCase()) - 12;
                    timezone = ((timezoneIndex < 0) ? ' -' : ' +') +
                        (('' + timezoneIndex).replace(/^-?/, '0')).match(/..$/)[0] + '00';
                }
                break;
            case 4: // Zone
                timezone = timezones[match[5]];
                break;
            default: // UT or +/-9999
                timezone = timezones[' GMT'];
        }
        match[5] = timezone;
        config._i = match.splice(1).join('');
        tzFormat = ' ZZ';
        config._f = dayFormat + dateFormat + timeFormat + tzFormat;
        configFromStringAndFormat(config);
        getParsingFlags(config).rfc2822 = true;
    } else {
        config._isValid = false;
    }
}
function configFromRFC2822 ( config ) { var string , match , dayFormat , dateFormat , timeFormat , tzFormat ; var timezones = { ' GMT' : ' +0000' , ' EDT' : ' -0400' , ' EST' : ' -0500' , ' CDT' : ' -0500' , ' CST' : ' -0600' , ' MDT' : ' -0600' , ' MST' : ' -0700' , ' PDT' : ' -0700' , ' PST' : ' -0800' } ; var military = 'YXWVUTSRQPONZABCDEFGHIKLM' ; var timezone , timezoneIndex ; string = config . _i . replace ( / \([^\)]*\)|[\n\t] / g , ' ' ) // Remove comments and folding whitespace . replace ( / (\s\s+) / g , ' ' ) // Replace multiple-spaces with a single space . replace ( / ^\s|\s$ / g , '' ) ; // Remove leading and trailing spaces match = basicRfcRegex . exec ( string ) ; if ( match ) { dayFormat = match [ 1 ] ? 'ddd' + ( ( match [ 1 ] . length === 5 ) ? ', ' : ' ' ) : '' ; dateFormat = 'D MMM ' + ( ( match [ 2 ] . length > 10 ) ? 'YYYY ' : 'YY ' ) ; timeFormat = 'HH:mm' + ( match [ 4 ] ? ':ss' : '' ) ; // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check. if ( match [ 1 ] ) { // day of week given var momentDate = new Date ( match [ 2 ] ) ; var momentDay = [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] [ momentDate . getDay ( ) ] ; if ( match [ 1 ] . substr ( 0 , 3 ) !== momentDay ) { getParsingFlags ( config ) . weekdayMismatch = true ; config . _isValid = false ; return ; } } switch ( match [ 5 ] . length ) { case 2 : // military if ( timezoneIndex === 0 ) { timezone = ' +0000' ; } else { timezoneIndex = military . indexOf ( match [ 5 ] [ 1 ] . toUpperCase ( ) ) - 12 ; timezone = ( ( timezoneIndex < 0 ) ? ' -' : ' +' ) + ( ( '' + timezoneIndex ) . replace ( / ^-? / , '0' ) ) . match ( / ..$ / ) [ 0 ] + '00' ; } break ; case 4 : // Zone timezone = timezones [ match [ 5 ] ] ; break ; default : // UT or +/-9999 timezone = timezones [ ' GMT' ] ; } match [ 5 ] = timezone ; config . _i = match . splice ( 1 ) . join ( '' ) ; tzFormat = ' ZZ' ; config . _f = dayFormat + dateFormat + timeFormat + tzFormat ; configFromStringAndFormat ( config ) ; getParsingFlags ( config ) . rfc2822 = true ; } else { config . _isValid = false ; } }
date and time from ref 2822 format
date and time from ref 2822 format