@carto/api-client 0.5.2-alpha.2 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "homepage": "https://github.com/CartoDB/carto-api-client#readme",
9
9
  "author": "Don McCurdy <donmccurdy@carto.com>",
10
10
  "packageManager": "yarn@4.3.1",
11
- "version": "0.5.2-alpha.2",
11
+ "version": "0.5.2",
12
12
  "license": "MIT",
13
13
  "publishConfig": {
14
14
  "access": "public"
@@ -128,6 +128,5 @@
128
128
  "resolutions": {
129
129
  "@carto/api-client": "portal:./",
130
130
  "rollup": "^4.20.0"
131
- },
132
- "stableVersion": "0.5.1"
131
+ }
133
132
  }
@@ -11,7 +11,6 @@ import {
11
11
  scaleThreshold,
12
12
  } from 'd3-scale';
13
13
  import {format as d3Format} from 'd3-format';
14
- import moment from 'moment-timezone';
15
14
 
16
15
  export type LayerType =
17
16
  | 'clusterTile'
@@ -22,7 +21,12 @@ export type LayerType =
22
21
  | 'raster'
23
22
  | 'tileset';
24
23
 
25
- import {createBinaryProxy, scaleIdentity} from './utils.js';
24
+ import {
25
+ createBinaryProxy,
26
+ formatDate,
27
+ formatTimestamp,
28
+ scaleIdentity,
29
+ } from './utils.js';
26
30
  import type {
27
31
  CustomMarkersRange,
28
32
  Dataset,
@@ -458,10 +462,10 @@ export function getSizeAccessor(
458
462
  }
459
463
 
460
464
  const FORMATS: Record<string, (value: any) => string> = {
461
- date: (s) => moment.utc(s).format('MM/DD/YY HH:mm:ssa'),
465
+ date: formatDate,
462
466
  integer: d3Format('i'),
463
467
  float: d3Format('.5f'),
464
- timestamp: (s) => moment.utc(s).format('X'),
468
+ timestamp: formatTimestamp,
465
469
  default: String,
466
470
  };
467
471
 
@@ -67,3 +67,21 @@ export function isRemoteCalculationSupported(dataset: Dataset) {
67
67
 
68
68
  return true;
69
69
  }
70
+
71
+ const DATE_FORMATTER = new Intl.DateTimeFormat('en-US', {
72
+ year: '2-digit',
73
+ month: 'numeric',
74
+ day: 'numeric',
75
+ hour: 'numeric',
76
+ minute: 'numeric',
77
+ second: 'numeric',
78
+ timeZone: 'UTC',
79
+ });
80
+
81
+ export function formatDate(value: string | number | Date): string {
82
+ return DATE_FORMATTER.format(new Date(value));
83
+ }
84
+
85
+ export function formatTimestamp(value: string | number | Date): string {
86
+ return String(Math.floor(new Date(value).getTime() / 1000));
87
+ }