Skip to content

Commit 7ac85a3

Browse files
authored
fix(ssh/settings): formats date value according to locale rules (#10468)
1 parent af5d3b7 commit 7ac85a3

File tree

9 files changed

+24
-7
lines changed

9 files changed

+24
-7
lines changed

tabby-core/src/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export { TabsService, NewTabParameters, TabComponentType } from '../services/tab
3636
export { UpdaterService } from '../services/updater.service'
3737
export { VaultService, Vault, VaultSecret, VaultFileSecret, VAULT_SECRET_TYPE_FILE, StoredVault, VaultSecretKey } from '../services/vault.service'
3838
export { FileProvidersService } from '../services/fileProviders.service'
39-
export { LocaleService } from '../services/locale.service'
39+
export { LocaleService, TabbyFormatedDatePipe } from '../services/locale.service'
4040
export { TranslateService } from '@ngx-translate/core'
4141
export * from '../utils'
4242
export { UTF8Splitter } from '../utfSplitter'

tabby-core/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import { AppService } from './services/app.service'
4343
import { ConfigService } from './services/config.service'
4444
import { VaultFileProvider } from './services/vault.service'
4545
import { HotkeysService } from './services/hotkeys.service'
46-
import { CustomMissingTranslationHandler, LocaleService } from './services/locale.service'
46+
import { CustomMissingTranslationHandler, LocaleService, TabbyFormatedDatePipe } from './services/locale.service'
4747
import { CommandService } from './services/commands.service'
4848

4949
import { NewTheme } from './theme'
@@ -130,6 +130,7 @@ const PROVIDERS = [
130130
DropZoneDirective,
131131
CdkAutoDropGroup,
132132
ProfileIconComponent,
133+
TabbyFormatedDatePipe,
133134
],
134135
exports: [
135136
AppRootComponent,
@@ -144,6 +145,7 @@ const PROVIDERS = [
144145
TranslateModule,
145146
CdkAutoDropGroup,
146147
ProfileIconComponent,
148+
TabbyFormatedDatePipe,
147149
],
148150
})
149151
export default class AppModule { // eslint-disable-line @typescript-eslint/no-extraneous-class

tabby-core/src/services/locale.service.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Injectable } from '@angular/core'
2-
import { registerLocaleData } from '@angular/common'
1+
import { Injectable, Pipe, PipeTransform } from '@angular/core'
2+
import { formatDate, registerLocaleData } from '@angular/common'
33
import { TranslateService, MissingTranslationHandler } from '@ngx-translate/core'
44
import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler'
55

@@ -257,3 +257,15 @@ export class LocaleService {
257257
return this.locale
258258
}
259259
}
260+
261+
@Pipe({
262+
name: 'tabbyDate',
263+
})
264+
export class TabbyFormatedDatePipe implements PipeTransform {
265+
266+
constructor (private locale: LocaleService) {}
267+
268+
transform (date: string): string {
269+
return formatDate(date, 'medium', this.locale.getLocale())
270+
}
271+
}

tabby-settings/src/components/configSyncSettingsTab.component.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
6767
div {{cfg.name}}
6868
small.text-muted(
6969
translate='Modified on {date}',
70-
[translateParams]='{date: cfg.modified_at|date:"medium"}'
70+
[translateParams]='{date: cfg.modified_at|tabbyDate}'
7171
)
7272
.me-auto
7373
button.btn.btn-link.ms-1(

tabby-settings/src/components/configSyncSettingsTab.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,5 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent {
145145
openTabbyWebInfo () {
146146
this.platform.openExternal('https://github.com/Eugeny/tabby-web')
147147
}
148+
148149
}

tabby-settings/src/components/releaseNotesTab.component.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
)
99
div(*ngFor='let release of releases')
1010
h1 {{release.name}}
11-
.text-muted {{release.version}} / {{release.date|date:'mediumDate'}}
11+
.text-muted {{release.version}} / {{release.date|tabbyDate}}
1212
section([fastHtmlBind]='release.content')

tabby-settings/src/components/releaseNotesTab.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ export class ReleaseNotesComponent extends BaseTabComponent {
4545
onScrolled () {
4646
this.loadReleases(this.lastPage + 1)
4747
}
48+
4849
}

tabby-ssh/src/components/sftpPanel.component.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@
6161
div {{item.name}}
6262
.me-auto
6363
.size(*ngIf='!item.isDirectory') {{item.size|filesize}}
64-
.date {{item.modified|date:'medium'}}
64+
.date {{item.modified|tabbyDate}}
6565
.mode {{getModeString(item)}}

tabby-ssh/src/components/sftpPanel.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,5 @@ export class SFTPPanelComponent {
273273
close (): void {
274274
this.closed.emit()
275275
}
276+
276277
}

0 commit comments

Comments
 (0)