Skip to content

Commit

Permalink
Handling additional space + text
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Mar 2, 2023
1 parent 0b98b7d commit cc2c1c2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion __mocks__/dh-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ class DateWrapper extends LongWrapper {

class TimeZone {
static getTimeZone(id) {
if (id == null || id === '') {
if (id == null || id === '' || id.includes(' ')) {
// Usually there would be a java.lang.IllegalArgumentException for any invalid id.
// We at least know that '' and undefined, so throw an error.
throw new Error('Unsupported time zone');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('isDateConditionValid', () => {
'2023-02-23T00:00:00 NY',
'2023-02-23 NY',
],
invalid: ['blah', '2023-02-23'],
invalid: ['blah', '2023-02-23', '2023-02-23T00:00:00 NY blah'],
empty: '',
undefined,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,10 @@ export function isDateConditionValid(condition: DateCondition, value?: string) {
return true;

default: {
const [dateTimeString, tzCode] = (value ?? '').split(' ');
const [dateTimeString, ...rest] = (value ?? '').split(' ');
// Reconstitute all tokens after the first ' ' in case the user included garbage data at the end
// e.g. '2020-01-01 NY blah'
const tzCode = rest.join(' ');

try {
DateUtils.parseDateTimeString(dateTimeString);
Expand Down

0 comments on commit cc2c1c2

Please sign in to comment.