Prettier code cleanup for .ts files

See #182
This commit is contained in:
Michael Shamoon
2022-03-11 10:53:32 -08:00
parent f8c8161a3e
commit f34202a82a
159 changed files with 3882 additions and 2716 deletions

View File

@@ -1,32 +1,47 @@
import { DatePipe } from '@angular/common';
import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core';
import { SettingsService, SETTINGS_KEYS } from '../services/settings.service';
import { DatePipe } from '@angular/common'
import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core'
import { SettingsService, SETTINGS_KEYS } from '../services/settings.service'
const FORMAT_TO_ISO_FORMAT = {
"longDate": "y-MM-dd",
"mediumDate": "y-MM-dd",
"shortDate": "y-MM-dd"
longDate: 'y-MM-dd',
mediumDate: 'y-MM-dd',
shortDate: 'y-MM-dd',
}
@Pipe({
name: 'customDate'
name: 'customDate',
})
export class CustomDatePipe implements PipeTransform {
private defaultLocale: string
constructor(@Inject(LOCALE_ID) locale: string, private datePipe: DatePipe, private settings: SettingsService) {
constructor(
@Inject(LOCALE_ID) locale: string,
private datePipe: DatePipe,
private settings: SettingsService
) {
this.defaultLocale = locale
}
transform(value: any, format?: string, timezone?: string, locale?: string): string | null {
let l = locale || this.settings.get(SETTINGS_KEYS.DATE_LOCALE) || this.defaultLocale
transform(
value: any,
format?: string,
timezone?: string,
locale?: string
): string | null {
let l =
locale ||
this.settings.get(SETTINGS_KEYS.DATE_LOCALE) ||
this.defaultLocale
let f = format || this.settings.get(SETTINGS_KEYS.DATE_FORMAT)
if (l == "iso-8601") {
if (l == 'iso-8601') {
return this.datePipe.transform(value, FORMAT_TO_ISO_FORMAT[f], timezone)
} else {
return this.datePipe.transform(value, format || this.settings.get(SETTINGS_KEYS.DATE_FORMAT), timezone, l)
return this.datePipe.transform(
value,
format || this.settings.get(SETTINGS_KEYS.DATE_FORMAT),
timezone,
l
)
}
}
}