From 75432123dc51abb61f8a66751d430ef4ae32eb01 Mon Sep 17 00:00:00 2001 From: jclark Date: Fri, 5 Apr 2024 13:13:17 +0100 Subject: [PATCH] common: clearer cursor output --- packages/common/src/Adaptor.js | 7 +++++-- packages/common/test/index.test.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/common/src/Adaptor.js b/packages/common/src/Adaptor.js index 942df87fe..e31c89d04 100644 --- a/packages/common/src/Adaptor.js +++ b/packages/common/src/Adaptor.js @@ -6,6 +6,7 @@ import { parse } from 'csv-parse'; import { Readable } from 'node:stream'; import { request } from 'undici'; +import { format } from 'date-fns'; import { expandReferences as newExpandReferences, parseDate } from './util'; @@ -821,8 +822,10 @@ export function cursor(value, options = {}) { const date = parseDate(cursor, cursorStart) if (date instanceof Date && date.toString !== "Invalid Date") { state[cursorKey] = date.toISOString(); - const humanLocaleDate = date.toLocaleString(undefined, { timeZoneName: 'short' }); - console.log(`Setting cursor "${cursor}" to: ${humanLocaleDate}`); + // Log the converted date in a very international, human-friendly format + // See https://date-fns.org/v3.6.0/docs/format + const formatted = format(date, 'HH:MM d MMM yyyy (OOO)') + console.log(`Setting cursor "${cursor}" to: ${formatted}`); return state; } } diff --git a/packages/common/test/index.test.js b/packages/common/test/index.test.js index 9a28d16f4..8d775da85 100644 --- a/packages/common/test/index.test.js +++ b/packages/common/test/index.test.js @@ -864,7 +864,7 @@ describe('validate', () => { }); }); -describe.only('cursor', () => { +describe('cursor', () => { it('should set a cursor on state', () => { const state = {} const result = cursor(1234)(state)