Skip to content

Commit

Permalink
fix: handle 12AM when converting to local time
Browse files Browse the repository at this point in the history
  • Loading branch information
Hein Jeong authored and hein-j committed Jan 25, 2023
1 parent 6855edc commit 1eb9541
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18096,7 +18096,7 @@ export default function BlogCreateForm(props) {
minute: \\"2-digit\\",
calendar: \\"iso8601\\",
numberingSystem: \\"latn\\",
hour12: false,
hourCycle: \\"h23\\",
});
const parts = df.formatToParts(date).reduce((acc, part) => {
acc[part.type] = part.value;
Expand Down Expand Up @@ -18692,7 +18692,7 @@ export default function InputGalleryCreateForm(props) {
minute: \\"2-digit\\",
calendar: \\"iso8601\\",
numberingSystem: \\"latn\\",
hour12: false,
hourCycle: \\"h23\\",
});
const parts = df.formatToParts(date).reduce((acc, part) => {
acc[part.type] = part.value;
Expand Down Expand Up @@ -19610,7 +19610,7 @@ export default function InputGalleryUpdateForm(props) {
minute: \\"2-digit\\",
calendar: \\"iso8601\\",
numberingSystem: \\"latn\\",
hour12: false,
hourCycle: \\"h23\\",
});
const parts = df.formatToParts(date).reduce((acc, part) => {
acc[part.type] = part.value;
Expand Down
6 changes: 3 additions & 3 deletions packages/codegen-ui-react/lib/utils/forms/value-mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const convertToLocal = (date: Date) => {
minute: '2-digit',
calendar: 'iso8601',
numberingSystem: 'latn',
hour12: false,
hourCycle: 'h23',
});
const parts = df.formatToParts(date).reduce<Record<string, string>>((acc, part) => {
acc[part.type] = part.value;
Expand Down Expand Up @@ -241,8 +241,8 @@ export const convertToLocalAST = factory.createVariableStatement(
factory.createStringLiteral('latn'),
),
factory.createPropertyAssignment(
factory.createIdentifier('hour12'),
factory.createFalse(),
factory.createIdentifier('hourCycle'),
factory.createStringLiteral('h23'),
),
],
true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ describe('CreateForms', () => {
getInputByLabel('Aws date').type('2022-10-12');
getInputByLabel('Aws time').type('10:12');
getInputByLabel('Aws date time').type('2017-06-01T08:30');
getInputByLabel('Aws timestamp').type('2022-12-01T10:30');
getInputByLabel('Aws timestamp').type('2022-12-01T00:30');

// handle chrome bug - https://support.google.com/chrome/thread/29828561?hl=en
getInputByLabel('Aws timestamp').should('have.value', '2022-12-01T00:30');

getInputByLabel('Aws email').type('myemail@yahoo.com');
getInputByLabel('Aws url').type('https://amazon.com');
getInputByLabel('Aws ip address').type('192.0.2.146');
Expand Down Expand Up @@ -197,7 +201,7 @@ describe('CreateForms', () => {
expect(record.awsDate).to.equal('2022-10-12');
expect(record.awsTime).to.equal('10:12');
expect(record.awsDateTime).to.equal('2017-06-01T08:30:00.000Z');
expect(record.awsTimestamp).to.equal(1669890600000);
expect(record.awsTimestamp).to.equal(1669854600000);
expect(record.awsEmail).to.equal('myemail@yahoo.com');
expect(record.awsUrl).to.equal('https://amazon.com');
expect(record.awsIPAddress).to.equal('192.0.2.146');
Expand Down

0 comments on commit 1eb9541

Please sign in to comment.