deno.land / x / pg_mem@2.8.1 / functions / date.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { FunctionDefinition } from '../interfaces.ts';import moment from 'https://deno.land/x/momentjs@2.29.1-deno/mod.ts';import { DataType, QueryError } from '../interfaces-private.ts';import { nullIsh } from '../utils.ts';

export const dateFunctions: FunctionDefinition[] = [ { name: 'to_date', args: [DataType.text, DataType.text], returns: DataType.date, implementation: (data, format) => { if (nullIsh(data) || nullIsh(format)) { return null; // if one argument is null => null } const ret = moment.utc(data, format); if (!ret.isValid()) { throw new QueryError(`The text '${data}' does not match the date format ${format}`); } return ret.toDate(); } }, { name: 'now', returns: DataType.timestamptz, impure: true, implementation: () => new Date(), },];
pg_mem

Version Info

Tagged at
4 months ago