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

wfnews-2407 #2106

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Changes from 1 commit
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
13 changes: 8 additions & 5 deletions client/wfnews-war/src/main/angular/src/app/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,20 +598,23 @@ export function getStageOfControlIcon(code: string) {
}
}

export function convertToDateTimeTimeZone(date) {
// e.g. July 19, 2022 at 10:22 a.m. PST
export function convertToDateTimeTimeZone(date: Date | string): string {
// e.g. July 19, 2022 at 10:22 a.m. PST/PDT
const updateOptions: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'long',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: undefined, // this removes the seconds
timeZone: 'America/Los_Angeles', // Pacific Time Zone
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to specify timezone? If somebody was using this from the eastern parts of BC, they would be getting the wrong time zone as they are one hour ahead. Would it be enough just to get rid of the fixed PST?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right, I forgot to consider some part of BC are off one hour.
Removed timezone option, thanks

timeZoneName: 'short', // Automatically handles PDT/PST
};
let convertedDate: string;
convertedDate = date
? new Date(date).toLocaleTimeString('en-US', updateOptions) + ' PST'

let convertedDate = date
? new Date(date).toLocaleString('en-US', updateOptions)
: 'Pending';

if (convertedDate !== 'Pending') {
// add full stops and lowercase
convertedDate = convertedDate.replace('AM', 'a.m.');
Expand Down
Loading