Skip to content

Conversation

@hoorayimhelping
Copy link
Contributor

@hoorayimhelping hoorayimhelping commented Jun 24, 2021

Closes #1767

import {createDateTimeFormatter} from 'src/utils/datetime/formatters'

const date = new Date(426196800000)

const formatter = createDateTimeFormatter('YYYY-MM-DD hh:mm:ss a')
formatter.format(date) // 1983-07-04 1:00:00 PM (for me, here on the west coast in summer)

const formatterUTC = createDateTimeFormatter('YYYY-MM-DD hh:mm:ss a', 'UTC')
formatter.format(date) // 1983-07-04 8:00:00 PM

Supports the formats enumerated by this list.

Co-authored-by: Beth Legesse blegesse@influxdata.com
Co-authored-by: Zoe Steinkamp zsteinkamp@influxdata.com
Co-authored-by: Palak Bhojani pbhojani@influxdata.com
Co-authored-by: Merrick Tian mtian@influxdata.com

@hoorayimhelping hoorayimhelping requested a review from a team as a code owner June 24, 2021 19:13
@hoorayimhelping hoorayimhelping requested a review from TCL735 June 24, 2021 19:13
@hoorayimhelping hoorayimhelping force-pushed the feat_datetime_formatter branch from 6cc6b20 to 5f9535d Compare June 24, 2021 19:26
@Palakp41
Copy link
Contributor

Not a blocker to merge this pr, but something handle later on. What if we add test cases and dynamically loop through those? So, we have cleaner and easier tests. Something like this:

const tests = [
  {x: 1, y: 2, r: 3}, 
  {x: 3, y: 4, r: 7}
];
describe('Adding method', () => { 
    for(let i = 0; i < tests.length; i++){
      it('should add its params', () => {
        const actual = sumModule(tests[i].x, tests[i].y);
        expect(actual).toBe(tests[i].r);
      });
    }
});

All the tests have the same wording, and we can update the format YYYY/MM/DD…. to be tests[i]?
so instead of:

it('formats DateTimes in the format YYYY-MM-DD hh:mm:ss a ZZ in UTC', () => {

we can do:

it(`formats DateTimes in the format ${tests[i]} in UTC`, () => {

Co-authored-by: Beth Legesse <blegesse@influxdata.com>
Co-authored-by: Zoe Steinkamp <zsteinkamp@influxdata.com>
Co-authored-by: Palak Bhojani <pbhojani@influxdata.com>
Co-authored-by: Merrick Tian <mtian@influxdata.com>
@hoorayimhelping hoorayimhelping force-pushed the feat_datetime_formatter branch from 62a9441 to 49abfd1 Compare June 24, 2021 19:47
@hoorayimhelping hoorayimhelping force-pushed the feat_datetime_formatter branch from 49abfd1 to 5291685 Compare June 24, 2021 19:49
@ui-ci-bot-influx
Copy link

Metric Score Level
performance 56 🔴
accessibility 96 🟢
seo 90 🟢
pwa null 💩
best-practices 93 🟢

Compare your scores with master branch

@hoorayimhelping hoorayimhelping merged commit 4c70add into master Jun 24, 2021
@hoorayimhelping hoorayimhelping deleted the feat_datetime_formatter branch June 24, 2021 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace Moment: create formatters and formatter factory methods

5 participants