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

[Bugfix] Time Formatting #2145

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

Civolilah
Copy link
Collaborator

@Civolilah Civolilah commented Oct 21, 2024

@beganovich @turbo124 The PR includes formatting of times in the app when we display them. Wherever I found a fixed time format, I replaced it with a dynamic one relying on the military_time company settings property. Screenshot:

Screenshot 2024-10-21 at 19 00 34

Let me know your thoughts.

Closes #2142

@Civolilah Civolilah marked this pull request as ready for review October 21, 2024 17:02
@@ -64,6 +65,22 @@ export function date(date: number | string, format: string) {
return dayjs(date).format(format);
}

export function useFormatTime() {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this a duplicate of useDateTime?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@beganovich Actually, it's not a duplicate because useFormatTime is dedicated only to formatting time values, while useDateTime formats the full date + time. However, since you mentioned it, I believe it's better to have it under useDateTime so we can make it more global. So, I've modified the useDateTime hook to accept time-only formatting. Let me know your thoughts.

}

return dayjs
.utc(date)
.tz(timeZone || companyTimeZone)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@beganovich After our quick discussion in the group about time zones, I'm now aware that we don't need to add timezone here. So, I've removed it.

Copy link
Member

Choose a reason for hiding this comment

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

But this hook is used in different places? Is the behavior same after your change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@beganovich Currently, the hook is only used in three places for formatting the next_send_datetime column value in Recurring Invoices. While we have many similar column formatting instances throughout the tables, this particular one formats both date and time.

The behavior will change as it will no longer use the company timezone. However, this aligns with our existing formatting logic, as we don't use company timezones for any other date or time column formatting in the application. The dayjs will take the timezone from the browser and format it into that timezone, which is how we handle all other formatting.

Basically change aligns logic with the rest of the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants