feat(date-converter): added mongodb objectID format

This commit is contained in:
Corentin Thomasset 2022-09-09 11:53:06 +02:00
parent 7f229959d6
commit 4ef25887b9
No known key found for this signature in database
GPG Key ID: DBD997E935996158

View File

@ -132,5 +132,10 @@ const formats: Format[] = [
fromDate: (date) => date.toUTCString(),
toDate,
},
{
name: 'Mongo ObjectID',
fromDate: (date) => Math.floor(date.getTime() / 1000).toString(16) + '0000000000000000',
toDate: (objectId) => new Date(parseInt(objectId.substring(0, 8), 16) * 1000),
},
];
</script>