Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP Staging]Remove zero prefix from time #25665

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const CONST = {
MOMENT_FORMAT_STRING: 'YYYY-MM-DD',
SQL_DATE_TIME: 'YYYY-MM-DD HH:mm:ss',
FNS_FORMAT_STRING: 'yyyy-MM-dd',
LOCAL_TIME_FORMAT: 'hh:mm a',
LOCAL_TIME_FORMAT: 'h:mm a',
WEEKDAY_TIME_FORMAT: 'eeee',
MONTH_DAY_ABBR_FORMAT: 'MMM d',
SHORT_DATE_FORMAT: 'MM-dd',
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/DateUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ describe('DateUtils', () => {

it('should return the date in calendar time when calling datetimeToCalendarTime', () => {
const today = setMinutes(setHours(new Date(), 14), 32);
expect(DateUtils.datetimeToCalendarTime(LOCALE, today)).toBe('Today at 02:32 PM');
expect(DateUtils.datetimeToCalendarTime(LOCALE, today)).toBe('Today at 2:32 PM');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mountiny Curious if the regression penalty should apply here because even the tests included the extra 0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were updated to have 0 in this PR, no? https://github.com/Expensify/App/pull/24446/files

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its something we have missed and should have addressed there, I think penalty should take place as this is a deploy blocker, but 25% seems more reasonable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but this was my mistake here, misunderstood the correct time format


const tomorrow = addDays(setMinutes(setHours(new Date(), 14), 32), 1);
expect(DateUtils.datetimeToCalendarTime(LOCALE, tomorrow)).toBe('Tomorrow at 02:32 PM');
expect(DateUtils.datetimeToCalendarTime(LOCALE, tomorrow)).toBe('Tomorrow at 2:32 PM');

const yesterday = setMinutes(setHours(subDays(new Date(), 1), 7), 43);
expect(DateUtils.datetimeToCalendarTime(LOCALE, yesterday)).toBe('Yesterday at 07:43 AM');
expect(DateUtils.datetimeToCalendarTime(LOCALE, yesterday)).toBe('Yesterday at 7:43 AM');

const date = setMinutes(setHours(new Date('2022-11-05'), 10), 17);
expect(DateUtils.datetimeToCalendarTime(LOCALE, date)).toBe('Nov 5, 2022 at 10:17 AM');

const todayLowercaseDate = setMinutes(setHours(new Date(), 14), 32);
expect(DateUtils.datetimeToCalendarTime(LOCALE, todayLowercaseDate, false, undefined, true)).toBe('today at 02:32 PM');
expect(DateUtils.datetimeToCalendarTime(LOCALE, todayLowercaseDate, false, undefined, true)).toBe('today at 2:32 PM');
});

it('should update timezone if automatic and selected timezone do not match', () => {
Expand Down