Skip to content

Commit

Permalink
common: clearer cursor output
Browse files Browse the repository at this point in the history
  • Loading branch information
josephjclark committed Apr 5, 2024
1 parent 1ad8665 commit 7543212
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/common/src/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7543212

Please sign in to comment.