MCPcopy Create free account
hub / github.com/chainjet/platform / getCreationDate

Function getCreationDate

apps/runner/src/utils/trigger.utils.ts:83–99  ·  view source on GitHub ↗
(item: Record<string, any>)

Source from the content-addressed store, hash-verified

81}
82
83export function getCreationDate(item: Record<string, any>): Date | undefined {
84 const createDateKey = Object.keys(item).find((key) =>
85 ['created_at', 'createdat', 'creationdate', 'creation_date', 'timestamp'].includes(key.toLowerCase()),
86 )
87 if (createDateKey) {
88 const dateIsNumber = Number.isFinite(Number(item[createDateKey]))
89 const dateInSeconds = dateIsNumber && item[createDateKey].toString().length === 10
90 const date = dateInSeconds
91 ? new Date(Number(item[createDateKey]) * 1000)
92 : dateIsNumber
93 ? new Date(Number(item[createDateKey])) // new Date returns invalid date for stringified numbers
94 : new Date(item[createDateKey])
95 if (!isNaN(date.getTime())) {
96 return date
97 }
98 }
99}
100
101export function getItemSchemaFromRes(idKey: string, schema: JSONSchema7): JSONSchema7 | null {
102 const objectKeys = idKey

Callers 3

extractTriggerItemsFunction · 0.85
sortByCreationDateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected