Skip to content

Commit 1383b50

Browse files
committed
ecer-5385 support to allow same day professional development
1 parent c9269c8 commit 1383b50

File tree

1 file changed

+5
-7
lines changed
  • src/ECER.Clients.RegistryPortal/ecer.clients.registryportal.client/src/utils

1 file changed

+5
-7
lines changed

src/ECER.Clients.RegistryPortal/ecer.clients.registryportal.client/src/utils/formRules.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ const notSameAs = (otherValue: string, message = "Both values must be different"
171171
const dateBetweenRule = (startDate: string, endDate: string, message = `Date should be between ${startDate} and ${endDate}`) => {
172172
return (v: string) => {
173173
if (v && startDate && endDate) {
174-
const end = DateTime.fromISO(endDate);
175-
const start = DateTime.fromISO(startDate);
176-
const input = DateTime.fromJSDate(new Date(v));
174+
const end = DateTime.fromISO(endDate).toUTC().startOf("day");
175+
const start = DateTime.fromISO(startDate).toUTC().startOf("day");
176+
const input = DateTime.fromJSDate(new Date(v)).toUTC();
177177

178178
return (input <= end && input >= start) || message;
179179
}
@@ -192,16 +192,14 @@ const dateBetweenRule = (startDate: string, endDate: string, message = `Date sho
192192
const dateBeforeRule = (targetDate: string, message = "End date cannot be before start date") => {
193193
return (v: string) => {
194194
if (v && targetDate) {
195-
const input = DateTime.fromJSDate(new Date(v));
196-
const target = DateTime.fromISO(targetDate);
195+
const input = DateTime.fromJSDate(new Date(v)).toUTC();
196+
const target = DateTime.fromISO(targetDate).toUTC().startOf("day");
197197

198198
return input >= target || message;
199199
}
200200

201201
return true;
202202
};
203-
204-
return true;
205203
};
206204

207205
/**

0 commit comments

Comments
 (0)