fix(investments): align roles and date contracts
Backend security / security (push) Successful in 9s
Backend verify / verify (push) Successful in 10m23s
Backend security / security (pull_request) Successful in 8s
Backend verify / verify (pull_request) Successful in 10m39s
Conventional commits / commits (pull_request) Successful in 29s
Backend security / security (push) Successful in 9s
Backend verify / verify (push) Successful in 10m23s
Backend security / security (pull_request) Successful in 8s
Backend verify / verify (pull_request) Successful in 10m39s
Conventional commits / commits (pull_request) Successful in 29s
Identify income dependencies by role and document screen-specific dates. Convert inclusive calendar days into half-open source ranges while preserving operation timestamps and existing stored coverage.
This commit is contained in:
@@ -1,10 +1,4 @@
|
||||
const MOSCOW_UTC_OFFSET_HOURS = 3;
|
||||
const MOSCOW_DAY_END_UTC = {
|
||||
hours: 20,
|
||||
minutes: 59,
|
||||
seconds: 59,
|
||||
milliseconds: 999,
|
||||
};
|
||||
export type DateOnlyRange = { from: string; to: string };
|
||||
const moscow = 'Europe/Moscow';
|
||||
const moscowFormatter = new Intl.DateTimeFormat('en-CA', {
|
||||
@@ -19,25 +13,21 @@ export function moscowDate(value: Date): string {
|
||||
return `${get('year')}-${get('month')}-${get('day')}`;
|
||||
}
|
||||
|
||||
export function dateOnlyBounds(range: DateOnlyRange): { from: Date; to: Date } {
|
||||
// Inclusive Moscow calendar dates become a half-open instant range, capped at now.
|
||||
export function dateOnlyBounds(
|
||||
range: DateOnlyRange,
|
||||
now = new Date(),
|
||||
): { from: Date; to: Date } {
|
||||
const from = dateParts(range.from);
|
||||
const end = dateParts(range.to);
|
||||
const to = new Date(
|
||||
Date.UTC(
|
||||
end[0],
|
||||
end[1] - 1,
|
||||
end[2],
|
||||
MOSCOW_DAY_END_UTC.hours,
|
||||
MOSCOW_DAY_END_UTC.minutes,
|
||||
MOSCOW_DAY_END_UTC.seconds,
|
||||
MOSCOW_DAY_END_UTC.milliseconds,
|
||||
),
|
||||
Date.UTC(end[0], end[1] - 1, end[2] + 1, -MOSCOW_UTC_OFFSET_HOURS),
|
||||
);
|
||||
return {
|
||||
from: new Date(
|
||||
Date.UTC(from[0], from[1] - 1, from[2], -MOSCOW_UTC_OFFSET_HOURS),
|
||||
),
|
||||
to: to > new Date() ? new Date() : to,
|
||||
to: to > now ? now : to,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user