swc/bundler/tests/.cache/deno/1a53b55b41069a12c154eb051f25deb05f797b90.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

82 lines
1.3 KiB
TypeScript

// Loaded from https://deno.land/x/segno@v1.1.0/lib/validations/isRFC3339.ts
/* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */
// @ts-ignore allowing typedoc to build
import { assertString } from '../helpers/assertString.ts';
/**
* @ignore
*/
const dateFullYear = /[0-9]{4}/;
/**
* @ignore
*/
const dateMonth = /(0[1-9]|1[0-2])/;
/**
* @ignore
*/
const dateMDay = /([12]\d|0[1-9]|3[01])/;
/**
* @ignore
*/
const timeHour = /([01][0-9]|2[0-3])/;
/**
* @ignore
*/
const timeMinute = /[0-5][0-9]/;
/**
* @ignore
*/
const timeSecond = /([0-5][0-9]|60)/;
/**
* @ignore
*/
const timeSecFrac = /(\.[0-9]+)?/;
/**
* @ignore
*/
const timeNumOffset = new RegExp(`[-+]${timeHour.source}:${timeMinute.source}`);
/**
* @ignore
*/
const timeOffset = new RegExp(`([zZ]|${timeNumOffset.source})`);
/**
* @ignore
*/
const partialTime = new RegExp(
`${timeHour.source}:${timeMinute.source}:${timeSecond.source}${timeSecFrac.source}`
);
/**
* @ignore
*/
const fullDate = new RegExp(
`${dateFullYear.source}-${dateMonth.source}-${dateMDay.source}`
);
/**
* @ignore
*/
const fullTime = new RegExp(`${partialTime.source}${timeOffset.source}`);
/**
* @ignore
*/
const rfc3339 = new RegExp(`${fullDate.source}[ tT]${fullTime.source}`);
export const isRFC3339 = (str: string) => {
assertString(str);
return rfc3339.test(str);
};