mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 19:25:23 +00:00
Moved processDate function to utils
This commit is contained in:
@@ -3,10 +3,9 @@ import { default as Bundle, filesSymbol } from "./Bundle";
|
||||
import { getModelFolderContents } from "./parser";
|
||||
import * as Schemas from "./schemas";
|
||||
import { Stream } from "stream";
|
||||
import { processDate } from "./processDate";
|
||||
import * as Signature from "./Signature";
|
||||
import * as Strings from "./StringsUtils";
|
||||
import { isValidRGB } from "./utils";
|
||||
import { isValidRGB, processDate } from "./utils";
|
||||
|
||||
/** Exporting for tests specs */
|
||||
export const propsSymbol = Symbol("props");
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import { dateToW3CString } from "./utils";
|
||||
import formatMessage, { ERROR, DEBUG } from "./messages";
|
||||
|
||||
export function processDate(key: string, date: Date): string | null {
|
||||
if (!(date instanceof Date)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const dateParse = dateToW3CString(date);
|
||||
|
||||
if (!dateParse) {
|
||||
console.warn(formatMessage(DEBUG.DATE_FORMAT_UNMATCH, key));
|
||||
return null;
|
||||
}
|
||||
|
||||
return dateParse;
|
||||
}
|
||||
17
src/utils.ts
17
src/utils.ts
@@ -26,6 +26,21 @@ export function isValidRGB(value?: string): boolean {
|
||||
return rgb.slice(1, 4).every((v) => Math.abs(Number(v)) <= 255);
|
||||
}
|
||||
|
||||
export function processDate(key: string, date: Date): string | null {
|
||||
if (!(date instanceof Date)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const dateParse = dateToW3CString(date);
|
||||
|
||||
if (!dateParse) {
|
||||
console.warn(formatMessage(DEBUG.DATE_FORMAT_UNMATCH, key));
|
||||
return null;
|
||||
}
|
||||
|
||||
return dateParse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a date to W3C Standard format
|
||||
*
|
||||
@@ -35,7 +50,7 @@ export function isValidRGB(value?: string): boolean {
|
||||
* undefined otherwise
|
||||
*/
|
||||
|
||||
export function dateToW3CString(date: Date) {
|
||||
function dateToW3CString(date: Date) {
|
||||
if (!(date instanceof Date)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user