diff --git a/tabby-core/src/api/index.ts b/tabby-core/src/api/index.ts index b55f7e76..5e92f700 100644 --- a/tabby-core/src/api/index.ts +++ b/tabby-core/src/api/index.ts @@ -36,7 +36,7 @@ export { TabsService, NewTabParameters, TabComponentType } from '../services/tab export { UpdaterService } from '../services/updater.service' export { VaultService, Vault, VaultSecret, VaultFileSecret, VAULT_SECRET_TYPE_FILE, StoredVault, VaultSecretKey } from '../services/vault.service' export { FileProvidersService } from '../services/fileProviders.service' -export { LocaleService } from '../services/locale.service' +export { LocaleService, TabbyFormatedDatePipe } from '../services/locale.service' export { TranslateService } from '@ngx-translate/core' export * from '../utils' export { UTF8Splitter } from '../utfSplitter' diff --git a/tabby-core/src/index.ts b/tabby-core/src/index.ts index 8d9f48df..79a02f58 100644 --- a/tabby-core/src/index.ts +++ b/tabby-core/src/index.ts @@ -43,7 +43,7 @@ import { AppService } from './services/app.service' import { ConfigService } from './services/config.service' import { VaultFileProvider } from './services/vault.service' import { HotkeysService } from './services/hotkeys.service' -import { CustomMissingTranslationHandler, LocaleService } from './services/locale.service' +import { CustomMissingTranslationHandler, LocaleService, TabbyFormatedDatePipe } from './services/locale.service' import { CommandService } from './services/commands.service' import { NewTheme } from './theme' @@ -130,6 +130,7 @@ const PROVIDERS = [ DropZoneDirective, CdkAutoDropGroup, ProfileIconComponent, + TabbyFormatedDatePipe, ], exports: [ AppRootComponent, @@ -144,6 +145,7 @@ const PROVIDERS = [ TranslateModule, CdkAutoDropGroup, ProfileIconComponent, + TabbyFormatedDatePipe, ], }) export default class AppModule { // eslint-disable-line @typescript-eslint/no-extraneous-class diff --git a/tabby-core/src/services/locale.service.ts b/tabby-core/src/services/locale.service.ts index 44c5975d..5a1e0b43 100644 --- a/tabby-core/src/services/locale.service.ts +++ b/tabby-core/src/services/locale.service.ts @@ -1,5 +1,5 @@ -import { Injectable } from '@angular/core' -import { registerLocaleData } from '@angular/common' +import { Injectable, Pipe, PipeTransform } from '@angular/core' +import { formatDate, registerLocaleData } from '@angular/common' import { TranslateService, MissingTranslationHandler } from '@ngx-translate/core' import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler' @@ -257,3 +257,15 @@ export class LocaleService { return this.locale } } + +@Pipe({ + name: 'tabbyDate', +}) +export class TabbyFormatedDatePipe implements PipeTransform { + + constructor (private locale: LocaleService) {} + + transform (date: string): string { + return formatDate(date, 'medium', this.locale.getLocale()) + } +} diff --git a/tabby-settings/src/components/configSyncSettingsTab.component.pug b/tabby-settings/src/components/configSyncSettingsTab.component.pug index b1f36d9c..4423d934 100644 --- a/tabby-settings/src/components/configSyncSettingsTab.component.pug +++ b/tabby-settings/src/components/configSyncSettingsTab.component.pug @@ -67,7 +67,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav') div {{cfg.name}} small.text-muted( translate='Modified on {date}', - [translateParams]='{date: cfg.modified_at|date:"medium"}' + [translateParams]='{date: cfg.modified_at|tabbyDate}' ) .me-auto button.btn.btn-link.ms-1( diff --git a/tabby-settings/src/components/configSyncSettingsTab.component.ts b/tabby-settings/src/components/configSyncSettingsTab.component.ts index 11a8a428..618ef295 100644 --- a/tabby-settings/src/components/configSyncSettingsTab.component.ts +++ b/tabby-settings/src/components/configSyncSettingsTab.component.ts @@ -145,4 +145,5 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent { openTabbyWebInfo () { this.platform.openExternal('https://github.com/Eugeny/tabby-web') } + } diff --git a/tabby-settings/src/components/releaseNotesTab.component.pug b/tabby-settings/src/components/releaseNotesTab.component.pug index ec59b68a..98fadb1a 100644 --- a/tabby-settings/src/components/releaseNotesTab.component.pug +++ b/tabby-settings/src/components/releaseNotesTab.component.pug @@ -8,5 +8,5 @@ ) div(*ngFor='let release of releases') h1 {{release.name}} - .text-muted {{release.version}} / {{release.date|date:'mediumDate'}} + .text-muted {{release.version}} / {{release.date|tabbyDate}} section([fastHtmlBind]='release.content') diff --git a/tabby-settings/src/components/releaseNotesTab.component.ts b/tabby-settings/src/components/releaseNotesTab.component.ts index 0b16595b..5a221d1a 100644 --- a/tabby-settings/src/components/releaseNotesTab.component.ts +++ b/tabby-settings/src/components/releaseNotesTab.component.ts @@ -45,4 +45,5 @@ export class ReleaseNotesComponent extends BaseTabComponent { onScrolled () { this.loadReleases(this.lastPage + 1) } + } diff --git a/tabby-ssh/src/components/sftpPanel.component.pug b/tabby-ssh/src/components/sftpPanel.component.pug index 67e4f202..a84ae2f5 100644 --- a/tabby-ssh/src/components/sftpPanel.component.pug +++ b/tabby-ssh/src/components/sftpPanel.component.pug @@ -61,5 +61,5 @@ div {{item.name}} .me-auto .size(*ngIf='!item.isDirectory') {{item.size|filesize}} - .date {{item.modified|date:'medium'}} + .date {{item.modified|tabbyDate}} .mode {{getModeString(item)}} diff --git a/tabby-ssh/src/components/sftpPanel.component.ts b/tabby-ssh/src/components/sftpPanel.component.ts index 38625c0f..8241ac22 100644 --- a/tabby-ssh/src/components/sftpPanel.component.ts +++ b/tabby-ssh/src/components/sftpPanel.component.ts @@ -273,4 +273,5 @@ export class SFTPPanelComponent { close (): void { this.closed.emit() } + }