Skip to content

Commit ff2187c

Browse files
authored
Release v1.51.3 (#1188)
## Changes - fix issue with incorrect short month (MMM) for September (Sept vs Sep) - landing page minor changes
2 parents fab7c84 + 23ae9d6 commit ff2187c

File tree

25 files changed

+207
-29
lines changed

25 files changed

+207
-29
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,5 @@
109109
"tsconfig-paths": "^4.2.0",
110110
"type-fest": "4.10.3"
111111
},
112-
"version": "1.51.2"
112+
"version": "1.51.3"
113113
}

packages/backend/src/apps/delay/__tests__/delay-until.test.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import '@/types/luxon-extensions'
2+
13
import { type IGlobalVariable } from '@plumber/types'
24

35
import { DateTime } from 'luxon'
@@ -11,6 +13,8 @@ import delayApp from '../index'
1113
const PAST_DATE = '2023-11-08'
1214
const VALID_DATE = '2026-12-31' // long long time later
1315
const VALID_TIME = '12:00'
16+
const VALID_DD_MMM_YYYY_SG = '01 Sept 2026' // test Sept format to convert to en-US
17+
const VALID_DD_MMM_YYYY_US = '01 Sep 2026'
1418
const DEFAULT_TIME = '00:00'
1519
const INVALID_TIME = '25:00'
1620
const INVALID_DATE = '2025-12-32'
@@ -89,6 +93,32 @@ describe('Delay until action', () => {
8993
})
9094
})
9195

96+
it('returns void and maintains Sept format in en-US', async () => {
97+
$.step.parameters = {
98+
delayUntil: VALID_DD_MMM_YYYY_US,
99+
delayUntilTime: VALID_TIME,
100+
}
101+
102+
const result = await delayUntilAction.run($)
103+
expect(result).toBeFalsy()
104+
expect(mocks.setActionItem).toBeCalledWith({
105+
raw: { delayUntil: VALID_DD_MMM_YYYY_US, delayUntilTime: VALID_TIME },
106+
})
107+
})
108+
109+
it('returns void and converts Sept to en-US from en-SG', async () => {
110+
$.step.parameters = {
111+
delayUntil: VALID_DD_MMM_YYYY_SG,
112+
delayUntilTime: VALID_TIME,
113+
}
114+
115+
const result = await delayUntilAction.run($)
116+
expect(result).toBeFalsy()
117+
expect(mocks.setActionItem).toBeCalledWith({
118+
raw: { delayUntil: VALID_DD_MMM_YYYY_US, delayUntilTime: VALID_TIME },
119+
})
120+
})
121+
92122
it('throws step error if delay until has a past timestamp', async () => {
93123
$.step.parameters = {
94124
delayUntil: PAST_DATE,
@@ -152,8 +182,8 @@ describe('Delay until action', () => {
152182
expect(result).toBeFalsy()
153183
expect(mocks.setActionItem).toBeCalledWith({
154184
raw: {
155-
delayUntil: DateTime.now().toFormat('dd MMM yyyy'),
156-
delayUntilTime: DateTime.now().toFormat('HH:mm'),
185+
delayUntil: DateTime.now().toPlumberFormat('dd MMM yyyy'),
186+
delayUntilTime: DateTime.now().toPlumberFormat('HH:mm'),
157187
},
158188
})
159189
})

packages/backend/src/apps/delay/actions/delay-until/index.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const action: IRawAction = {
3333
key: 'delayUntil',
3434
type: 'string' as const,
3535
required: true,
36-
description: 'Delay until the date. E.g. 25 Aug 2023',
36+
description: 'Delay until the date. E.g. 05 Aug 2026',
3737
variables: true,
3838
},
3939
{
@@ -61,8 +61,23 @@ const action: IRawAction = {
6161
delayUntilTimeString,
6262
)
6363

64+
// check if delayUntilString is of dd MMM yyyy format, if so, force en-US to maintain consistency with FormSG
65+
let delayUntilFormatted = delayUntilString
66+
// Try parsing with en-SG first (for "Sept"), then en-US (for "Sep"), this is for the test case to work because it is not aware of the en-US locale
67+
let dateTime = DateTime.fromFormat(delayUntilString, 'dd MMM yyyy', {
68+
locale: 'en-SG',
69+
})
70+
if (!dateTime.isValid) {
71+
dateTime = DateTime.fromFormat(delayUntilString, 'dd MMM yyyy', {
72+
locale: 'en-US',
73+
})
74+
}
75+
if (dateTime.isValid) {
76+
delayUntilFormatted = dateTime.toPlumberFormat('dd MMM yyyy')
77+
}
78+
6479
let dataItem = {
65-
delayUntil: delayUntilString,
80+
delayUntil: delayUntilFormatted,
6681
delayUntilTime: delayUntilTimeString,
6782
}
6883

@@ -85,8 +100,8 @@ const action: IRawAction = {
85100
if (isRetry) {
86101
const dateTimeNow = DateTime.now()
87102
dataItem = {
88-
delayUntil: dateTimeNow.toFormat('dd MMM yyyy'),
89-
delayUntilTime: dateTimeNow.toFormat('HH:mm'),
103+
delayUntil: dateTimeNow.toPlumberFormat('dd MMM yyyy'),
104+
delayUntilTime: dateTimeNow.toPlumberFormat('HH:mm'),
90105
}
91106
} else {
92107
throw new StepError(

packages/backend/src/apps/formatter/__tests__/date-time.add-subtract.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import '@/types/luxon-extensions'
2+
13
import { IGlobalVariable } from '@plumber/types'
24

35
import { Settings as LuxonSettings } from 'luxon'

packages/backend/src/apps/formatter/__tests__/date-time.common.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import '@/types/luxon-extensions'
2+
13
import { DateTime, Settings as LuxonSettings } from 'luxon'
24
import { describe, expect, it } from 'vitest'
35

packages/backend/src/apps/formatter/__tests__/date-time.format.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import '@/types/luxon-extensions'
2+
13
import { IGlobalVariable } from '@plumber/types'
24

35
import { Settings as LuxonSettings } from 'luxon'
@@ -138,4 +140,42 @@ describe('convert date time', () => {
138140
raw: { result: expectedResult },
139141
})
140142
})
143+
144+
it.each([
145+
{
146+
inputFormat: 'formsgDateField',
147+
inputValue: '01 Sept 2025',
148+
toFormat: 'dd LLL yyyy',
149+
expectedResult: '01 Sep 2025',
150+
},
151+
{
152+
inputFormat: 'formsgDateField',
153+
inputValue: '02 Sep 2025',
154+
toFormat: 'dd LLL yyyy',
155+
expectedResult: '02 Sep 2025',
156+
},
157+
{
158+
inputFormat: 'dd LLL yyyy hh:mm a',
159+
inputValue: '03 Sep 2025 11:50 pm',
160+
toFormat: 'dd LLL yyyy',
161+
expectedResult: '03 Sep 2025',
162+
},
163+
{
164+
inputFormat: 'dd LLL yyyy hh:mm:ss a',
165+
inputValue: '04 Sept 2025 11:45:30 pm',
166+
toFormat: 'dd LLL yyyy hh:mm a',
167+
expectedResult: '04 Sep 2025 11:45 pm',
168+
},
169+
])('converts dd MMM yyyy format from en-SG to en-US', (testParams) => {
170+
const { inputFormat, inputValue, toFormat, expectedResult } = testParams
171+
$.step.parameters = {
172+
dateTimeFormat: inputFormat,
173+
formatDateTimeToFormat: toFormat,
174+
}
175+
spec.transformData($, inputValue)
176+
177+
expect(mocks.setActionItem).toBeCalledWith({
178+
raw: { result: expectedResult },
179+
})
180+
})
141181
})

packages/backend/src/apps/formatter/actions/date-time/common/date-time-format.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ const formatConverters = Object.assign({
5858
// en-US parsing failed, fall back to en-SG.
5959
return DateTime.fromFormat(input, 'dd MMM yyyy')
6060
},
61-
stringify: (dateTime: DateTime): string => dateTime.toFormat('dd MMM yyyy'),
61+
stringify: (dateTime: DateTime): string =>
62+
dateTime.toPlumberFormat('dd MMM yyyy'),
6263
},
6364
...Object.fromEntries(
6465
commonDateFormats
@@ -67,9 +68,19 @@ const formatConverters = Object.assign({
6768
format,
6869
{
6970
description: format,
70-
parse: (input: string): DateTime =>
71-
DateTime.fromFormat(input, format),
72-
stringify: (dateTime: DateTime): string => dateTime.toFormat(format),
71+
parse: (input: string): DateTime => {
72+
const result = DateTime.fromFormat(input, format, {
73+
locale: 'en-US',
74+
})
75+
if (result.isValid) {
76+
return result
77+
}
78+
return DateTime.fromFormat(input, format, {
79+
locale: 'en-SG',
80+
})
81+
},
82+
stringify: (dateTime: DateTime): string =>
83+
dateTime.toPlumberFormat(format),
7384
},
7485
]),
7586
),

packages/backend/src/apps/formatter/actions/date-time/transforms/convert-date-time/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const spec = {
5252

5353
$.setActionItem({
5454
raw: {
55-
result: dateTime.toFormat(formatString),
55+
result: dateTime.toPlumberFormat(formatString),
5656
},
5757
})
5858
} catch (error) {

packages/backend/src/apps/lettersg/actions/create-letter/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const responseSchema = z
6767
// Have to set to en-US to process the month "Sep" while en-SG only accepts "Sept"
6868
createdAt: DateTime.fromFormat(data.createdAt, 'EEE MMM dd yyyy', {
6969
locale: 'en-US',
70-
}).toFormat(
70+
}).toPlumberFormat(
7171
'dd MMM yyyy', // format a time usable for other steps
7272
),
7373
}))

0 commit comments

Comments
 (0)