From 3afa7759371a9f0e639b839ea9ba380da6bb6bca Mon Sep 17 00:00:00 2001 From: Victor Usoltsev Date: Mon, 4 Oct 2021 23:00:08 +1300 Subject: [PATCH] Updates short date formatting to use user's browser preference. --- .../src/app/issues/issueDetails.component.html | 2 +- .../tv-request-grid/tv-request-grid.component.html | 2 +- .../tv-requests/tv-requests-panel.component.html | 2 +- src/Ombi/ClientApp/src/app/pipes/UserLocalePipe.ts | 12 ++++++++++++ src/Ombi/ClientApp/src/app/pipes/pipe.module.ts | 5 +++-- .../app/requests/tvrequest-children.component.html | 2 +- .../src/app/search/moviesearchgrid.component.html | 2 +- .../src/app/search/music/albumsearch.component.html | 2 +- .../src/app/search/seriesinformation.component.html | 2 +- .../ClientApp/src/app/search/tvsearch.component.html | 2 +- .../src/app/shared/chat-box/chat-box.component.html | 2 +- .../episode-request/episode-request.component.html | 2 +- .../app/usermanagement/usermanagement.component.html | 8 ++++---- 13 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 src/Ombi/ClientApp/src/app/pipes/UserLocalePipe.ts diff --git a/src/Ombi/ClientApp/src/app/issues/issueDetails.component.html b/src/Ombi/ClientApp/src/app/issues/issueDetails.component.html index b5fc59304..58d31cffa 100644 --- a/src/Ombi/ClientApp/src/app/issues/issueDetails.component.html +++ b/src/Ombi/ClientApp/src/app/issues/issueDetails.component.html @@ -63,7 +63,7 @@

{{comment.comment}}

- +
diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.html b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.html index d7ce108fa..926e73901 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.html @@ -44,7 +44,7 @@ {{ 'Requests.AirDate' | translate }} - {{element.airDate | amLocal | amDateFormat: 'L' }} + {{element.airDate | amLocal | amUserLocale | amDateFormat: 'L' }} diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.html b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.html index 0945c5a51..c7db6af5d 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.html @@ -39,7 +39,7 @@ {{ 'Requests.AirDate' | translate }} - {{element.airDate | amLocal | amDateFormat: 'L' }} + {{element.airDate | amLocal | amUserLocale | amDateFormat: 'L' }} diff --git a/src/Ombi/ClientApp/src/app/pipes/UserLocalePipe.ts b/src/Ombi/ClientApp/src/app/pipes/UserLocalePipe.ts new file mode 100644 index 000000000..ec59c21c9 --- /dev/null +++ b/src/Ombi/ClientApp/src/app/pipes/UserLocalePipe.ts @@ -0,0 +1,12 @@ +import { Pipe, PipeTransform } from "@angular/core"; +import * as moment from "moment"; + +const momentConstructor = moment; + +@Pipe({ name: "amUserLocale" }) +export class UserLocalePipe implements PipeTransform { + transform(value: moment.MomentInput): moment.Moment { + const locale = navigator.language; + return momentConstructor(value).locale(locale); + } +} diff --git a/src/Ombi/ClientApp/src/app/pipes/pipe.module.ts b/src/Ombi/ClientApp/src/app/pipes/pipe.module.ts index a947851b3..8e084ec3d 100644 --- a/src/Ombi/ClientApp/src/app/pipes/pipe.module.ts +++ b/src/Ombi/ClientApp/src/app/pipes/pipe.module.ts @@ -3,11 +3,12 @@ import { HumanizePipe } from "./HumanizePipe"; import { ThousandShortPipe } from "./ThousandShortPipe"; import { SafePipe } from "./SafePipe"; import { QualityPipe } from "./QualityPipe"; +import { UserLocalePipe } from "./UserLocalePipe"; @NgModule({ imports: [], - declarations: [HumanizePipe, ThousandShortPipe, SafePipe, QualityPipe], - exports: [HumanizePipe, ThousandShortPipe, SafePipe, QualityPipe], + declarations: [HumanizePipe, ThousandShortPipe, SafePipe, QualityPipe, UserLocalePipe], + exports: [HumanizePipe, ThousandShortPipe, SafePipe, QualityPipe, UserLocalePipe], }) export class PipeModule { diff --git a/src/Ombi/ClientApp/src/app/requests/tvrequest-children.component.html b/src/Ombi/ClientApp/src/app/requests/tvrequest-children.component.html index b0e301d34..abb4f8e18 100644 --- a/src/Ombi/ClientApp/src/app/requests/tvrequest-children.component.html +++ b/src/Ombi/ClientApp/src/app/requests/tvrequest-children.component.html @@ -86,7 +86,7 @@ {{ep.title}} - {{ep.airDate | amLocal | amDateFormat: 'L' }} + {{ep.airDate | amLocal | amUserLocale | amDateFormat: 'L' }} {{result.title}} ({{result.releaseDate | amLocal | amDateFormat: 'YYYY'}}) - Release Date: {{result.releaseDate | amLocal | amDateFormat: 'L'}} + Release Date: {{result.releaseDate | amLocal | amUserLocale | amDateFormat: 'L'}} HomePage diff --git a/src/Ombi/ClientApp/src/app/search/music/albumsearch.component.html b/src/Ombi/ClientApp/src/app/search/music/albumsearch.component.html index c63a7bfa3..8c06ca297 100644 --- a/src/Ombi/ClientApp/src/app/search/music/albumsearch.component.html +++ b/src/Ombi/ClientApp/src/app/search/music/albumsearch.component.html @@ -54,7 +54,7 @@ - Release Date: {{result.releaseDate | amLocal | amDateFormat: 'L'}} + Release Date: {{result.releaseDate | amLocal | amUserLocale | amDateFormat: 'L'}} {{result.rating}}/10 diff --git a/src/Ombi/ClientApp/src/app/search/seriesinformation.component.html b/src/Ombi/ClientApp/src/app/search/seriesinformation.component.html index 12059e417..97309e4ff 100644 --- a/src/Ombi/ClientApp/src/app/search/seriesinformation.component.html +++ b/src/Ombi/ClientApp/src/app/search/seriesinformation.component.html @@ -43,7 +43,7 @@ {{ep.title}} - {{ep.airDate | amLocal | amDateFormat: 'L' }} + {{ep.airDate | amLocal | amUserLocale | amDateFormat: 'L' }} {{ep.airDateDisplay }} diff --git a/src/Ombi/ClientApp/src/app/search/tvsearch.component.html b/src/Ombi/ClientApp/src/app/search/tvsearch.component.html index b46cab574..51b61e0a4 100644 --- a/src/Ombi/ClientApp/src/app/search/tvsearch.component.html +++ b/src/Ombi/ClientApp/src/app/search/tvsearch.component.html @@ -84,7 +84,7 @@ {{node.status}} - {{ 'Search.TvShows.AirDate' | translate }} {{node.firstAired | amLocal | amDateFormat: 'L'}} + {{ 'Search.TvShows.AirDate' | translate }} {{node.firstAired | amLocal | amUserLocale | amDateFormat: 'L'}} {{node.network}} diff --git a/src/Ombi/ClientApp/src/app/shared/chat-box/chat-box.component.html b/src/Ombi/ClientApp/src/app/shared/chat-box/chat-box.component.html index 59a200703..201c10a9f 100644 --- a/src/Ombi/ClientApp/src/app/shared/chat-box/chat-box.component.html +++ b/src/Ombi/ClientApp/src/app/shared/chat-box/chat-box.component.html @@ -13,7 +13,7 @@

{{m.username}}


{{m.message}}

-

{{m.date | amLocal | amDateFormat: 'l LT'}}

+

{{m.date | amFromUtc | amLocal | amUserLocale | amDateFormat: 'l LT'}}

diff --git a/src/Ombi/ClientApp/src/app/shared/episode-request/episode-request.component.html b/src/Ombi/ClientApp/src/app/shared/episode-request/episode-request.component.html index 5eed5c313..9c97c73f1 100644 --- a/src/Ombi/ClientApp/src/app/shared/episode-request/episode-request.component.html +++ b/src/Ombi/ClientApp/src/app/shared/episode-request/episode-request.component.html @@ -42,7 +42,7 @@ {{ep.title}}
- {{ep.airDate | amLocal | amDateFormat: 'L' }} + {{ep.airDate | amLocal | amUserLocale | amDateFormat: 'L' }}
{{ep.airDateDisplay }} diff --git a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.html b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.html index 719c18591..67d303d7d 100644 --- a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.html +++ b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.html @@ -61,13 +61,13 @@ Next Request Due
- {{'UserManagment.MovieDue' | translate: {date: (u.movieRequestQuota.nextRequest | amLocal | amDateFormat: 'l')} }} + {{'UserManagment.MovieDue' | translate: {date: (u.movieRequestQuota.nextRequest | amLocal | amUserLocale | amDateFormat: 'l')} }}
- {{'UserManagment.TvDue' | translate: {date: (u.episodeRequestQuota.nextRequest | amLocal | amDateFormat: 'l')} }} + {{'UserManagment.TvDue' | translate: {date: (u.episodeRequestQuota.nextRequest | amLocal | amUserLocale | amDateFormat: 'l')} }}
- {{'UserManagment.MusicDue' | translate: {date: (u.musicRequestQuota.nextRequest | amLocal | amDateFormat: 'l')} }} + {{'UserManagment.MusicDue' | translate: {date: (u.musicRequestQuota.nextRequest | amLocal | amUserLocale | amDateFormat: 'l')} }}
@@ -75,7 +75,7 @@ Last Logged In - {{u.lastLoggedIn | amFromUtc | amLocal | amDateFormat: 'l LT'}} + {{u.lastLoggedIn | amFromUtc | amLocal | amUserLocale | amDateFormat: 'l LT'}} Not logged in yet!