Skip to content

Commit 6ac4903

Browse files
author
dphuang2
committed
fix date issue
1 parent 4646ce5 commit 6ac4903

File tree

6 files changed

+40
-3
lines changed

6 files changed

+40
-3
lines changed

generator/konfig-next-app/src/components/ParameterInput.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,19 +236,24 @@ export function ParameterInput({
236236
parameter.schema.format === 'date'
237237
) {
238238
const { value, onChange, ...rest } = inputProps
239+
const parsed = parseDateString(value)
239240
return (
240241
<DatePickerInput
241242
icon={<IconCalendar size="1.1rem" stroke={1.5} />}
242243
clearable
243-
value={parseDateString(value)}
244+
value={parsed}
244245
onChange={(date) => {
245246
if (date === null) {
246247
onChange('')
247248
return
248249
}
249250
if (date instanceof Date) {
251+
const YYYYMMDD = `${date.getFullYear()}-${(date.getMonth() + 1)
252+
.toString()
253+
.padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`
254+
console.log(YYYYMMDD)
250255
// converts date to YYYY-MM-DD format
251-
onChange(date.toISOString().split('T')[0])
256+
onChange(YYYYMMDD)
252257
}
253258
}}
254259
{...rest}

generator/konfig-next-app/src/utils/code-generator-httpsnippet.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ test('httpsnippet - HAR validation error', async () => {
4747
packageName: 'leap_workflows',
4848
projectName: 'leap-python-sdk',
4949
git: gitConfig,
50+
disabled: false,
5051
},
5152
},
5253
servers: ['https://api.workflows.tryleap.ai'],
@@ -163,6 +164,7 @@ test('httpsnippet - deeply nested objects with files', async () => {
163164
packageName: 'groundx',
164165
projectName: 'groundx-python-sdk',
165166
git: gitConfig,
167+
disabled: false,
166168
},
167169
},
168170
servers: ['https://api.groundx.ai/api'],
@@ -246,6 +248,7 @@ test('generate "requestBody" parameter when non-request body parameter and reque
246248
owner: 'konfig-dev',
247249
path: 'bellhop-sdks/tree/main/python',
248250
},
251+
disabled: false,
249252
},
250253
},
251254
servers: [
@@ -463,6 +466,7 @@ test('request body should not be used if schema is object', async () => {
463466
owner: 'konfig-dev',
464467
path: 'bellhop-sdks/tree/main/python',
465468
},
469+
disabled: false,
466470
},
467471
},
468472
servers: [

generator/konfig-next-app/src/utils/code-generator-python.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ test('nested object property names should not be converted to snake_case', async
112112
owner: 'groundxai',
113113
path: 'groundx-sdks/tree/main/sdks/python',
114114
},
115+
disabled: false,
115116
},
116117
},
117118
servers: ['https://api.groundx.ai/api'],
@@ -228,6 +229,7 @@ test('deeply nested objects with file', async () => {
228229
packageName: 'groundx',
229230
projectName: 'groundx-python-sdk',
230231
git: gitConfig,
232+
disabled: false,
231233
},
232234
},
233235
servers: ['https://api.groundx.ai/api'],
@@ -397,6 +399,7 @@ test('nested objects does not have empty properties', async () => {
397399
packageName: 'groundx',
398400
projectName: 'groundx-python-sdk',
399401
git: gitConfig,
402+
disabled: false,
400403
},
401404
},
402405
servers: ['https://api.groundx.ai/api'],
@@ -523,6 +526,7 @@ test('request body with blob values', async () => {
523526
packageName: 'groundx',
524527
projectName: 'groundx-python-sdk',
525528
git: gitConfig,
529+
disabled: false,
526530
},
527531
},
528532
servers: ['https://api.groundx.ai/api'],
@@ -588,6 +592,7 @@ test('simple example', async () => {
588592
packageName: 'snaptrade_client',
589593
projectName: 'groundx-python-sdk',
590594
git: gitConfig,
595+
disabled: false,
591596
},
592597
},
593598
requestBody: null,
@@ -678,6 +683,7 @@ test('simple parameters example', async () => {
678683
packageName: 'snaptrade_client',
679684
projectName: 'groundx-python-sdk',
680685
git: gitConfig,
686+
disabled: false,
681687
},
682688
},
683689
requestBody: null,
@@ -833,6 +839,7 @@ it('example with boolean', async () => {
833839
packageName: 'snaptrade_client',
834840
projectName: 'groundx-python-sdk',
835841
git: gitConfig,
842+
disabled: false,
836843
},
837844
},
838845
tag: 'Authentication',
@@ -1016,6 +1023,7 @@ it('example with inner object', async () => {
10161023
packageName: 'snaptrade_client',
10171024
projectName: 'groundx-python-sdk',
10181025
git: gitConfig,
1026+
disabled: false,
10191027
},
10201028
},
10211029
securitySchemes: {
@@ -1086,6 +1094,7 @@ it('example with no setup', async () => {
10861094
packageName: 'snaptrade_client',
10871095
projectName: 'snaptrade-python-sdk',
10881096
git: gitConfig,
1097+
disabled: false,
10891098
},
10901099
},
10911100
tag: 'Options',
@@ -1150,6 +1159,7 @@ it('example with no form data but > 1 parameters', async () => {
11501159
packageName: 'snaptrade_client',
11511160
projectName: 'snaptrade-python-sdk',
11521161
git: gitConfig,
1162+
disabled: false,
11531163
},
11541164
},
11551165
tag: 'Options',

generator/konfig-next-app/src/utils/code-generator-typescript.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ test('deeply nested objects with file', async () => {
109109
packageName: 'groundx',
110110
projectName: 'groundx-python-sdk',
111111
git: gitConfig,
112+
disabled: false,
112113
},
113114
},
114115
servers: ['https://api.groundx.ai/api'],
@@ -278,6 +279,7 @@ test('nested objects does not have empty properties', async () => {
278279
packageName: 'groundx',
279280
projectName: 'groundx-python-sdk',
280281
git: gitConfig,
282+
disabled: false,
281283
},
282284
},
283285
servers: ['https://api.groundx.ai/api'],
@@ -611,6 +613,7 @@ test('request body with blob values', async () => {
611613
packageName: 'groundx',
612614
projectName: 'groundx-python-sdk',
613615
git: gitConfig,
616+
disabled: false,
614617
},
615618
},
616619
servers: ['https://api.groundx.ai/api'],
@@ -676,6 +679,7 @@ test('simple example', async () => {
676679
packageName: 'snaptrade_client',
677680
projectName: 'snaptrade-python-sdk',
678681
git: gitConfig,
682+
disabled: false,
679683
},
680684
},
681685
requestBody: null,
@@ -766,6 +770,7 @@ test('simple parameters example', async () => {
766770
packageName: 'snaptrade_client',
767771
projectName: 'snaptrade-python-sdk',
768772
git: gitConfig,
773+
disabled: false,
769774
},
770775
},
771776
requestBody: null,
@@ -921,6 +926,7 @@ it('example with boolean', async () => {
921926
packageName: 'snaptrade_client',
922927
projectName: 'snaptrade-python-sdk',
923928
git: gitConfig,
929+
disabled: false,
924930
},
925931
},
926932
tag: 'Authentication',
@@ -1104,6 +1110,7 @@ it('example with inner object', async () => {
11041110
packageName: 'snaptrade_client',
11051111
projectName: 'snaptrade-python-sdk',
11061112
git: gitConfig,
1113+
disabled: false,
11071114
},
11081115
},
11091116
securitySchemes: {
@@ -1558,6 +1565,7 @@ it('example with no setup', async () => {
15581565
packageName: 'snaptrade_client',
15591566
projectName: 'snaptrade-python-sdk',
15601567
git: gitConfig,
1568+
disabled: false,
15611569
},
15621570
},
15631571
tag: 'Options',
@@ -1655,6 +1663,7 @@ it('still generate parameters when non-request body parameter and request body p
16551663
owner: 'konfig-dev',
16561664
path: 'bellhop-sdks/tree/main/python',
16571665
},
1666+
disabled: false,
16581667
},
16591668
},
16601669
servers: [
@@ -1755,6 +1764,7 @@ it('generate "requestBody" parameter when non-request body parameter and request
17551764
owner: 'konfig-dev',
17561765
path: 'bellhop-sdks/tree/main/python',
17571766
},
1767+
disabled: false,
17581768
},
17591769
},
17601770
servers: [
@@ -1801,6 +1811,7 @@ it('tag with PascalCase is properly converted to camelCase', async () => {
18011811
packageName: 'test',
18021812
projectName: 'test',
18031813
git: gitConfig,
1814+
disabled: false,
18041815
},
18051816
},
18061817
tag: 'ShouldBeCamelCase',
@@ -1865,6 +1876,7 @@ it('example with no form data but > 1 parameters', async () => {
18651876
packageName: 'snaptrade_client',
18661877
projectName: 'snaptrade-python-sdk',
18671878
git: gitConfig,
1879+
disabled: false,
18681880
},
18691881
},
18701882
tag: 'Options',

generator/konfig-next-app/src/utils/code-generator.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ function testArgs(): CodeGeneratorConstructorArgs {
6161
packageName: 'test',
6262
projectName: 'test',
6363
git: gitConfig,
64+
disabled: false,
6465
},
6566
},
6667
tag: 'Test',

generator/konfig-next-app/src/utils/parse-date-string.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@
55
*/
66
export function parseDateString(str: string): Date | null {
77
const date = new Date(str)
8-
return date.toString() === 'Invalid Date' ? null : date
8+
if (date.toString() === 'Invalid Date') return null
9+
// Get the timezone offset in minutes
10+
const timezoneOffsetMinutes = date.getTimezoneOffset()
11+
// Adjust the date by the timezone offset
12+
const adjustedDate = new Date(date.getTime() + timezoneOffsetMinutes * 60000)
13+
return adjustedDate.toString() === 'Invalid Date' ? null : adjustedDate
914
}

0 commit comments

Comments
 (0)