Skip to content

Commit

Permalink
Merge pull request #4320 from bernarden/feature/all-short-dates-shoul…
Browse files Browse the repository at this point in the history
…d-be-formatted-according-to-user-browser-preferences

Updates short date formatting to use user's browser preference.
  • Loading branch information
tidusjar committed Oct 4, 2021
2 parents 8a5804e + 3afa775 commit d15ddb6
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h3 class="panel-title">

<div class="messages msg_sent"> <i *ngIf="isAdmin" style="float:right;" class="fas fa-times" aria-hidden="true" (click)="deleteComment(comment.id)"></i>
<p>{{comment.comment}}</p>
<time>{{comment.username}} • {{comment.date | amLocal | amDateFormat: 'l LT'}}</time>
<time>{{comment.username}} • {{comment.date | amFromUtc | amLocal | amUserLocale | amDateFormat: 'l LT'}}</time>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

<ng-container matColumnDef="airDate">
<th mat-header-cell *matHeaderCellDef> {{ 'Requests.AirDate' | translate }} </th>
<td mat-cell *matCellDef="let element"> {{element.airDate | amLocal | amDateFormat: 'L' }}</td>
<td mat-cell *matCellDef="let element"> {{element.airDate | amLocal | amUserLocale | amDateFormat: 'L' }}</td>
</ng-container>

<ng-container matColumnDef="status">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<ng-container matColumnDef="airDate">
<th mat-header-cell *matHeaderCellDef> {{ 'Requests.AirDate' | translate }} </th>
<td mat-cell *matCellDef="let element"> {{element.airDate | amLocal | amDateFormat: 'L' }}</td>
<td mat-cell *matCellDef="let element"> {{element.airDate | amLocal | amUserLocale | amDateFormat: 'L' }}</td>
</ng-container>

<ng-container matColumnDef="status">
Expand Down
12 changes: 12 additions & 0 deletions src/Ombi/ClientApp/src/app/pipes/UserLocalePipe.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
5 changes: 3 additions & 2 deletions src/Ombi/ClientApp/src/app/pipes/pipe.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h2>{{ 'Requests.Season' | translate }} {{season.seasonNumber}}</h2>
{{ep.title}}
</td>
<td>
{{ep.airDate | amLocal | amDateFormat: 'L' }}
{{ep.airDate | amLocal | amUserLocale | amDateFormat: 'L' }}
</td>
<td>
<span *ngIf="child.denied" class="label label-danger" id="deniedLabel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<h4>{{result.title}} ({{result.releaseDate | amLocal | amDateFormat: 'YYYY'}})</h4>
</a>

<span *ngIf="result.releaseDate" class="label label-info" target="_blank">Release Date: {{result.releaseDate | amLocal | amDateFormat: 'L'}}</span>
<span *ngIf="result.releaseDate" class="label label-info" target="_blank">Release Date: {{result.releaseDate | amLocal | amUserLocale | amDateFormat: 'L'}}</span>

<a *ngIf="result.homepage" href="{{result.homepage}}" id="homepageLabel" target="_blank">
<span class="label label-info">HomePage</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h5>


<ng-template [ngIf]="result.releaseDate">
<span class="label label-info" id="availableLabel">Release Date: {{result.releaseDate | amLocal | amDateFormat: 'L'}}</span>
<span class="label label-info" id="availableLabel">Release Date: {{result.releaseDate | amLocal | amUserLocale | amDateFormat: 'L'}}</span>
</ng-template>
<ng-template [ngIf]="result.rating">
<span class="label label-info" id="availableLabel">{{result.rating}}/10</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h2 [translate]="'Requests.SeasonNumberHeading'" [translateParams]="{seasonNumbe
{{ep.title}}
</td>
<td *ngIf="ep.airDateDisplay != 'Unknown'">
{{ep.airDate | amLocal | amDateFormat: 'L' }}
{{ep.airDate | amLocal | amUserLocale | amDateFormat: 'L' }}
</td>
<td *ngIf="ep.airDateDisplay == 'Unknown'">
{{ep.airDateDisplay }}
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi/ClientApp/src/app/search/tvsearch.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h4>{{node.title}} ({{node.firstAired | amLocal | amDateFormat: 'YYYY'}})</h4>
<span *ngIf="node.status" class="label label-primary" id="statusLabel" target="_blank">{{node.status}}</span>


<span *ngIf="node.firstAired" class="label label-info" target="_blank" id="airDateLabel">{{ 'Search.TvShows.AirDate' | translate }} {{node.firstAired | amLocal | amDateFormat: 'L'}}</span>
<span *ngIf="node.firstAired" class="label label-info" target="_blank" id="airDateLabel">{{ 'Search.TvShows.AirDate' | translate }} {{node.firstAired | amLocal | amUserLocale | amDateFormat: 'L'}}</span>

<span *ngIf="node.network" class="label label-info" id="networkLabel" target="_blank">{{node.network}}</span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1>Users</h1>
<p class="name" *ngIf="m?.username">{{m.username}}</p>
<br/>
<p class="message">{{m.message}}</p>
<p class="timestamp">{{m.date | amLocal | amDateFormat: 'l LT'}}</p>
<p class="timestamp">{{m.date | amFromUtc | amLocal | amUserLocale | amDateFormat: 'l LT'}}</p>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
{{ep.title}}
</div>
<div class="col-2" *ngIf="ep.airDateDisplay != 'Unknown'">
{{ep.airDate | amLocal | amDateFormat: 'L' }}
{{ep.airDate | amLocal | amUserLocale | amDateFormat: 'L' }}
</div>
<div class="col-2" *ngIf="ep.airDateDisplay == 'Unknown'">
{{ep.airDateDisplay }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@
<th mat-header-cell *matHeaderCellDef> Next Request Due </th>
<td mat-cell *matCellDef="let u">
<div *ngIf="u.movieRequestQuota != null && u.movieRequestQuota.remaining != u.movieRequestLimit">
{{'UserManagment.MovieDue' | translate: {date: (u.movieRequestQuota.nextRequest | amLocal | amDateFormat: 'l')} }}
{{'UserManagment.MovieDue' | translate: {date: (u.movieRequestQuota.nextRequest | amLocal | amUserLocale | amDateFormat: 'l')} }}
</div>
<div *ngIf="u.episodeRequestQuota != null && u.episodeRequestQuota.remaining != u.episodeRequestLimit">
{{'UserManagment.TvDue' | translate: {date: (u.episodeRequestQuota.nextRequest | amLocal | amDateFormat: 'l')} }}
{{'UserManagment.TvDue' | translate: {date: (u.episodeRequestQuota.nextRequest | amLocal | amUserLocale | amDateFormat: 'l')} }}
</div>
<div *ngIf="u.musicRequestQuota != null && u.musicRequestQuota.remaining != u.musicRequestLimit">
{{'UserManagment.MusicDue' | translate: {date: (u.musicRequestQuota.nextRequest | amLocal | amDateFormat: 'l')} }}
{{'UserManagment.MusicDue' | translate: {date: (u.musicRequestQuota.nextRequest | amLocal | amUserLocale | amDateFormat: 'l')} }}
</div>
</td>
</ng-container>
<ng-container matColumnDef="lastLoggedIn">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Last Logged In </th>
<td mat-cell *matCellDef="let u">
<span *ngIf="u.lastLoggedIn">
{{u.lastLoggedIn | amFromUtc | amLocal | amDateFormat: 'l LT'}}
{{u.lastLoggedIn | amFromUtc | amLocal | amUserLocale | amDateFormat: 'l LT'}}
</span>
<span *ngIf="!u.lastLoggedIn">
Not logged in yet!
Expand Down

0 comments on commit d15ddb6

Please sign in to comment.