Skip to content

Commit

Permalink
chore: review remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtreier committed Sep 17, 2024
1 parent fc73d9e commit 8806186
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,6 @@ export const localDateAdapter: PolicyFormAdapter<Date | null> = {
}),
};

export const stringAdapter: PolicyFormAdapter<string> = {
displayText: (literal): string | null =>
readSingleStringLiteral(literal) ?? '',
fromControlFactory: () => new UntypedFormControl('', Validators.required),
buildFormValueFn: (literal): string => readSingleStringLiteral(literal) ?? '',
buildValueFn: (value) => stringLiteral(value),
emptyConstraintValue: () => ({
operator: 'EQ',
right: {
type: 'STRING',
value: '',
},
}),
};

export const stringArrayOrCommaJoinedAdapter: PolicyFormAdapter<string[]> = {
displayText: (literal): string | null => readArrayLiteral(literal).join(', '),
fromControlFactory: () => new UntypedFormControl([], Validators.required),
Expand Down
6 changes: 3 additions & 3 deletions src/app/core/utils/date-utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {addDays, subDays} from 'date-fns';
import {format} from 'date-fns-tz';

/**
* Takes the year/month/day information of a local date and creates a new Date object from it.
* Hour offset context is removed.
* Can be used to ensure dates are displayed identically across different timezones when stringified in JSON payloads.
* @param date date to convert
*/
import {addDays, subDays} from 'date-fns';
import {format} from 'date-fns-tz';

export function toGmtZeroHourDate(date: Date): Date {
return new Date(format(date, 'yyyy-MM-dd'));
}
Expand Down

0 comments on commit 8806186

Please sign in to comment.