fix: use localized date and time

This commit is contained in:
Michel Jonathan Schmitz
2021-02-09 16:59:50 +00:00
committed by Wieland Schöbl
parent 8280917312
commit 6ca0b97637
12 changed files with 17 additions and 47 deletions

View File

@@ -13,9 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Component, Input} from '@angular/core';
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
import {SCLanguageCode, SCMessage} from '@openstapps/core';
import {Subscription} from 'rxjs';
import {SCMessage} from '@openstapps/core';
/**
* News page component
*/
@@ -29,31 +27,5 @@ export class NewsItemComponent {
* News (message) to show
*/
@Input() item: SCMessage;
/**
* Current language
*/
language: string;
/**
* Current language subscription
*/
languageSubscription: Subscription;
constructor(private translateService: TranslateService) {}
/**
* Remove language subscription on component destruction
*/
ngOnDestroy() {
this.languageSubscription?.unsubscribe();
}
/**
* Initialize the local variables on component initialization
*/
ngOnInit() {
this.language = this.translateService.currentLang as SCLanguageCode;
this.languageSubscription = this.translateService.onLangChange.subscribe((event: LangChangeEvent) => {
this.language = event.lang as SCLanguageCode;
});
}
}

View File

@@ -14,9 +14,7 @@
</ion-thumbnail>
</ng-template>
<ion-card-header>
<ion-card-subtitle *ngIf="item.datePublished">{{item.datePublished | amLocale: language | amDateFormat:'Do MMMM YYYY, HH:mm'}}
<span *ngIf="language === 'de'">Uhr</span>
</ion-card-subtitle>
<ion-card-subtitle *ngIf="item.datePublished">{{item.datePublished | amDateFormat:'LLL'}}</ion-card-subtitle>
<ion-card-title>
<span *ngIf="item.url; else titleNoUrl"><a href="{{item.url}}"><span class="text">{{item.name}}</span><span class="icon"><ion-icon name="open-outline"></ion-icon></span></a></span>
<ng-template #titleNoUrl>{{item.name}}</ng-template>