mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
17 lines
454 B
TypeScript
17 lines
454 B
TypeScript
import { Injectable } from '@angular/core'
|
|
import { TuiDay, TuiValueTransformer } from '@taiga-ui/cdk'
|
|
|
|
type From = TuiDay | null
|
|
type To = string | null
|
|
|
|
@Injectable()
|
|
export class DateTransformerService extends TuiValueTransformer<From, To> {
|
|
fromControlValue(controlValue: To): From {
|
|
return controlValue ? TuiDay.jsonParse(controlValue) : null
|
|
}
|
|
|
|
toControlValue(componentValue: From): To {
|
|
return componentValue?.toJSON() || null
|
|
}
|
|
}
|