Skip to content

Commit 1fa4c2f

Browse files
Copilotlarsdecker
andcommitted
Fix date arithmetic and simplify macOS date commands
Co-authored-by: larsdecker <1968186+larsdecker@users.noreply.github.com>
1 parent 651a89f commit 1fa4c2f

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,8 @@ const client = new PinTanClient({
133133
const accounts = await client.accounts();
134134

135135
// Fetch last 30 days of transactions
136-
const startDate = new Date();
137-
startDate.setDate(startDate.getDate() - 30);
138136
const endDate = new Date();
137+
const startDate = new Date(endDate.getTime() - 30 * 24 * 60 * 60 * 1000);
139138

140139
const statements = await client.statements(accounts[0], startDate, endDate);
141140

packages/fints-cli/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ fints-lib fetch-transactions \
283283
START_DATE=$(date -d "last month" +%Y-%m-01)
284284
END_DATE=$(date -d "-1 day $(date +%Y-%m-01)" +%Y-%m-%d)
285285

286-
# For macOS (BSD date), use:
287-
# START_DATE=$(date -v-1m +%Y-%m-01)
288-
# END_DATE=$(date -v1d -v-1m -v-1d +%Y-%m-%d)
289-
# Or install GNU coreutils (brew install coreutils) and use 'gdate'
286+
# For macOS (BSD date), install GNU coreutils and use 'gdate':
287+
# brew install coreutils
288+
# START_DATE=$(gdate -d "last month" +%Y-%m-01)
289+
# END_DATE=$(gdate -d "-1 day $(gdate +%Y-%m-01)" +%Y-%m-%d)
290290

291291
# Fetch transactions
292292
fints-lib fetch-transactions \

packages/fints/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ const accounts = await client.accounts();
232232

233233
// Get transactions from the last 30 days
234234
const endDate = new Date();
235-
const startDate = new Date();
236-
startDate.setDate(startDate.getDate() - 30);
235+
const startDate = new Date(endDate.getTime() - 30 * 24 * 60 * 60 * 1000);
237236

238237
const statements = await client.statements(accounts[0], startDate, endDate);
239238

0 commit comments

Comments
 (0)