appwrite-utils
Advanced tools
Comparing version 0.3.94 to 0.3.95
@@ -494,9 +494,23 @@ import { DateTime } from "luxon"; | ||
"yyyy-MM-dd HH:mm", | ||
"M/d/yyyy h:mm:ss tt", // U.S. style with 12-hour clock | ||
"d/M/yyyy h:mm:ss tt", // Rest of the world style with 12-hour clock | ||
"h:mm tt", // Time only with 12-hour clock | ||
// 12-hour clock formats with and without spaces | ||
"M/d/yyyy h:mm:ss a", // U.S. style with 12-hour clock | ||
"M/d/yyyy h:mm:ss tt", // Alternative AM/PM format | ||
"M/d/yyyy h:mma", // Compact format without seconds | ||
"M/d/yyyy h:mm a", // With space | ||
"d/M/yyyy h:mm:ss a", // Rest of world with 12-hour clock | ||
"d/M/yyyy h:mm:ss tt", | ||
"d/M/yyyy h:mma", | ||
"d/M/yyyy h:mm a", | ||
"h:mm:ss a", // Time only with 12-hour clock | ||
"h:mm:ss tt", | ||
"h:mma", | ||
"h:mm a", | ||
"HH:mm:ss", // Time only with 24-hour clock | ||
"HH:mm", // Time only without seconds, 24-hour clock | ||
"h:mm tt M/d/yyyy", // 12-hour clock time followed by U.S. style date | ||
"h:mm tt d/M/yyyy", // 12-hour clock time followed by Rest of the world style date | ||
"h:mm a M/d/yyyy", // 12-hour clock time followed by U.S. style date | ||
"h:mma M/d/yyyy", | ||
"h:mm tt M/d/yyyy", | ||
"h:mm a d/M/yyyy", // 12-hour clock time followed by Rest of world style date | ||
"h:mma d/M/yyyy", | ||
"h:mm tt d/M/yyyy", | ||
"yyyy-MM-dd'T'HH:mm:ss.SSSZ", // ISO 8601 with timezone offset | ||
@@ -510,2 +524,6 @@ "yyyy-MM-dd'T'HH:mm:ssZ", // ISO 8601 without milliseconds but with timezone offset | ||
]; | ||
// Normalize input string to handle various AM/PM formats | ||
let normalizedInput = String(input) | ||
.replace(/(\d)(AM|PM)/i, "$1 $2") // Add space between time and AM/PM if missing | ||
.replace(/(\d)([AaPp])([Mm])?/, "$1 $2M"); // Normalize 'a' or 'p' to 'AM' or 'PM' | ||
// Attempt to parse as a timestamp first if input is a number | ||
@@ -519,9 +537,9 @@ if (typeof input === "number") { | ||
// Attempt to parse as an ISO string or SQL string | ||
let date = DateTime.fromISO(String(input)); | ||
let date = DateTime.fromISO(normalizedInput); | ||
if (!date.isValid) | ||
date = DateTime.fromSQL(String(input)); | ||
date = DateTime.fromSQL(normalizedInput); | ||
// Try each custom format if still not valid | ||
for (const format of formats) { | ||
if (!date.isValid) { | ||
date = DateTime.fromFormat(String(input), format); | ||
date = DateTime.fromFormat(normalizedInput, format); | ||
} | ||
@@ -528,0 +546,0 @@ } |
{ | ||
"name": "appwrite-utils", | ||
"module": "dist/index.js", | ||
"version": "0.3.94", | ||
"version": "0.3.95", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "types": "dist/index.d.ts", |
@@ -75,2 +75,3 @@ # appwrite-utils | ||
- 0.3.95: Updated `safeParseDate` to handle formats like `8:00AM` vs `8:00 AM` -- spaces matter! | ||
- 0.3.94: Updated `getFilePreviewUrl` -- it was missing the `&` if you didn't use a JWT | ||
@@ -77,0 +78,0 @@ - 0.3.93: Forgot to export it 👁👄👁 |
@@ -493,9 +493,23 @@ import { DateTime } from "luxon"; | ||
"yyyy-MM-dd HH:mm", | ||
"M/d/yyyy h:mm:ss tt", // U.S. style with 12-hour clock | ||
"d/M/yyyy h:mm:ss tt", // Rest of the world style with 12-hour clock | ||
"h:mm tt", // Time only with 12-hour clock | ||
// 12-hour clock formats with and without spaces | ||
"M/d/yyyy h:mm:ss a", // U.S. style with 12-hour clock | ||
"M/d/yyyy h:mm:ss tt", // Alternative AM/PM format | ||
"M/d/yyyy h:mma", // Compact format without seconds | ||
"M/d/yyyy h:mm a", // With space | ||
"d/M/yyyy h:mm:ss a", // Rest of world with 12-hour clock | ||
"d/M/yyyy h:mm:ss tt", | ||
"d/M/yyyy h:mma", | ||
"d/M/yyyy h:mm a", | ||
"h:mm:ss a", // Time only with 12-hour clock | ||
"h:mm:ss tt", | ||
"h:mma", | ||
"h:mm a", | ||
"HH:mm:ss", // Time only with 24-hour clock | ||
"HH:mm", // Time only without seconds, 24-hour clock | ||
"h:mm tt M/d/yyyy", // 12-hour clock time followed by U.S. style date | ||
"h:mm tt d/M/yyyy", // 12-hour clock time followed by Rest of the world style date | ||
"h:mm a M/d/yyyy", // 12-hour clock time followed by U.S. style date | ||
"h:mma M/d/yyyy", | ||
"h:mm tt M/d/yyyy", | ||
"h:mm a d/M/yyyy", // 12-hour clock time followed by Rest of world style date | ||
"h:mma d/M/yyyy", | ||
"h:mm tt d/M/yyyy", | ||
"yyyy-MM-dd'T'HH:mm:ss.SSSZ", // ISO 8601 with timezone offset | ||
@@ -510,2 +524,7 @@ "yyyy-MM-dd'T'HH:mm:ssZ", // ISO 8601 without milliseconds but with timezone offset | ||
// Normalize input string to handle various AM/PM formats | ||
let normalizedInput = String(input) | ||
.replace(/(\d)(AM|PM)/i, "$1 $2") // Add space between time and AM/PM if missing | ||
.replace(/(\d)([AaPp])([Mm])?/, "$1 $2M"); // Normalize 'a' or 'p' to 'AM' or 'PM' | ||
// Attempt to parse as a timestamp first if input is a number | ||
@@ -520,4 +539,4 @@ if (typeof input === "number") { | ||
// Attempt to parse as an ISO string or SQL string | ||
let date = DateTime.fromISO(String(input)); | ||
if (!date.isValid) date = DateTime.fromSQL(String(input)); | ||
let date = DateTime.fromISO(normalizedInput); | ||
if (!date.isValid) date = DateTime.fromSQL(normalizedInput); | ||
@@ -527,3 +546,3 @@ // Try each custom format if still not valid | ||
if (!date.isValid) { | ||
date = DateTime.fromFormat(String(input), format); | ||
date = DateTime.fromFormat(normalizedInput, format); | ||
} | ||
@@ -530,0 +549,0 @@ } |
371425
9600
97