@butinapp/sdk 0.1.1 → 0.1.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/dist/util/date.d.ts +1 -0
- package/dist/util/date.js +5 -0
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.js +1 -1
- package/package.json +1 -1
package/dist/util/date.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const dayOf: (value?: string | null) => string | undefined;
|
|
|
9
9
|
export declare const monthKey: (year: number, month: number) => string;
|
|
10
10
|
export declare const currentMonthKey: (now?: Date) => string;
|
|
11
11
|
export declare const dayMinus: (day: string, days: number) => string;
|
|
12
|
+
export declare const monthMinus: (day: string, months: number) => string;
|
|
12
13
|
export declare const utcDaysAgo: (days: number) => string;
|
|
13
14
|
export declare const isoDaysAgo: (days: number, now?: Date) => string;
|
|
14
15
|
export declare const monthStart: (now?: Date) => string;
|
package/dist/util/date.js
CHANGED
|
@@ -41,6 +41,11 @@ export const currentMonthKey = (now = new Date()) => DateTime.fromJSDate(now, {
|
|
|
41
41
|
// 'YYYY-MM-DD' for `days` before `day` (a UTC 'YYYY-MM-DD'). Day-string arithmetic goes through luxon, so callers
|
|
42
42
|
// never re-roll millisecond math; invalid input returns `day` unchanged.
|
|
43
43
|
export const dayMinus = (day, days) => DateTime.fromISO(day, { zone: 'utc' }).minus({ days }).toISODate() ?? day;
|
|
44
|
+
// 'YYYY-MM-DD' for `months` calendar months before `day`. Luxon handles month-length edges (Mar 31 − 1 → Feb 28).
|
|
45
|
+
// Bucketing arithmetic on a day string, so the reporting zone doesn't apply; invalid input returns `day` unchanged.
|
|
46
|
+
// The go-to for arrears billing: an invoice issued in month M covers M − 1, so `monthMinus(issueDay, 1)` books it
|
|
47
|
+
// into the month it actually covers regardless of which day of M it was issued.
|
|
48
|
+
export const monthMinus = (day, months) => DateTime.fromISO(day, { zone: 'utc' }).minus({ months }).toISODate() ?? day;
|
|
44
49
|
// UTC 'YYYY-MM-DD' for N days before now.
|
|
45
50
|
export const utcDaysAgo = (days) => new Date(Date.now() - days * MS_PER_DAY).toISOString().slice(0, 10);
|
|
46
51
|
// Full UTC ISO datetime N days before `now` — the start of a since-window passed to usage/event APIs.
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { centsToMajor, centsStringToMajor, millicentsToMajor, parseDecimalAmount, round2, parseFrAmount } from './money.js';
|
|
2
|
-
export { isoDay, dayOf, epochMsDay, epochSecDay, monthKey, currentMonthKey, dayMinus, utcDaysAgo, isoDaysAgo, monthStart, getReportingZone, setReportingZone, MS_PER_DAY, MONTH_ABBR } from './date.js';
|
|
2
|
+
export { isoDay, dayOf, epochMsDay, epochSecDay, monthKey, currentMonthKey, dayMinus, monthMinus, utcDaysAgo, isoDaysAgo, monthStart, getReportingZone, setReportingZone, MS_PER_DAY, MONTH_ABBR } from './date.js';
|
|
3
3
|
export { startCase, parseDollarAmount } from './text.js';
|
|
4
4
|
export { convert } from './fx.js';
|
|
5
5
|
export type { FxRates } from './fx.js';
|
package/dist/util/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// their leaf names already read clearly, and a namespace prefix would shadow common locals (`date`, `fx`).
|
|
4
4
|
// (Generic third-party utilities — lodash + luxon — live on @butinapp/sdk/libs.)
|
|
5
5
|
export { centsToMajor, centsStringToMajor, millicentsToMajor, parseDecimalAmount, round2, parseFrAmount } from './money.js';
|
|
6
|
-
export { isoDay, dayOf, epochMsDay, epochSecDay, monthKey, currentMonthKey, dayMinus, utcDaysAgo, isoDaysAgo, monthStart, getReportingZone, setReportingZone, MS_PER_DAY, MONTH_ABBR } from './date.js';
|
|
6
|
+
export { isoDay, dayOf, epochMsDay, epochSecDay, monthKey, currentMonthKey, dayMinus, monthMinus, utcDaysAgo, isoDaysAgo, monthStart, getReportingZone, setReportingZone, MS_PER_DAY, MONTH_ABBR } from './date.js';
|
|
7
7
|
export { startCase, parseDollarAmount } from './text.js';
|
|
8
8
|
export { convert } from './fx.js';
|
|
9
9
|
export { omitUndef, asArray } from './object.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@butinapp/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "The Butin plugin-authoring contract: descriptor types, the data-view result contract, presets, and edge utilities.",
|
|
5
5
|
"homepage": "https://butin.app",
|
|
6
6
|
"bugs": "https://github.com/butinapp/butin/issues",
|