dayjs#ConfigType TypeScript Examples
The following examples show how to use
dayjs#ConfigType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: component.ts From alauda-ui with MIT License | 5 votes |
confirmValue(value?: ConfigType, closeAfterConfirm = true) {
this.emitValue(value ? dayjs(value) : this.selectedDate);
closeAfterConfirm && this.confirm.next(null);
}
Example #2
Source File: component.ts From alauda-ui with MIT License | 5 votes |
@Input()
maxAvail?: ConfigType;
Example #3
Source File: component.ts From alauda-ui with MIT License | 5 votes |
@Input()
minAvail?: ConfigType;
Example #4
Source File: date-picker.component.ts From alauda-ui with MIT License | 5 votes |
override valueIn(obj: ConfigType) {
return obj ? dayjs(obj) : null;
}
Example #5
Source File: range-picker.component.ts From alauda-ui with MIT License | 5 votes |
override valueIn(obj: [ConfigType, ConfigType]) {
return obj?.map(i => dayjs(i));
}
Example #6
Source File: range-picker.component.ts From alauda-ui with MIT License | 5 votes |
@Component({
selector: 'aui-range-picker',
templateUrl: './range-picker.template.html',
// provide tooltip class
encapsulation: ViewEncapsulation.Emulated,
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => RangePickerComponent),
multi: true,
},
],
changeDetection: ChangeDetectionStrategy.OnPush,
styleUrls: ['./range-picker.style.scss'],
})
export class RangePickerComponent extends CommonFormControl<
ConfigType[],
Dayjs[]
> {
@Input()
clearable = true;
@Input()
clearText: string;
@Input()
format = 'YYYY-MM-DD';
@Input()
showFooter = true;
@Input()
showTime = true;
@Input()
disabledDate: DisabledDateFn = () => false;
@Input()
minDate: Dayjs;
@Input()
maxDate: Dayjs;
@Input()
disabledTime: { left: DisabledTimeFn; right: DisabledTimeFn } = {
left: () => null,
right: () => null,
};
@Input()
weekStartDay = 0;
@Input()
size: ComponentSize;
@Output()
openChange = new EventEmitter<boolean>();
value: [Dayjs, Dayjs];
override valueIn(obj: [ConfigType, ConfigType]) {
return obj?.map(i => dayjs(i));
}
override writeValue(obj: [Dayjs, Dayjs]) {
super.writeValue(obj);
this.value = obj;
this.cdr.markForCheck();
}
clearValue() {
this.value = null;
this.emitValue(null);
}
}
Example #7
Source File: dayjs.ts From back-home-safe with GNU General Public License v3.0 | 5 votes |
dayjs = (date?: ConfigType) =>
_(date).locale(i18n.language.toLowerCase())
Example #8
Source File: dayjs.ts From tencent-component-toolkit with MIT License | 5 votes |
function formatDate(date: ConfigType, withTimeout = false): string {
return dtz(date).format(withTimeout ? TIME_FORMAT_TIMEZONE : TIME_FORMAT);
}
Example #9
Source File: dayjs.ts From tencent-component-toolkit with MIT License | 5 votes |
dtz = (date: ConfigType = Date.now()) => {
return dayjs.tz(date);
}
Example #10
Source File: date-picker.component.ts From alauda-ui with MIT License | 4 votes |
@Component({
selector: 'aui-date-picker',
templateUrl: './date-picker.template.html',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.Emulated,
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => DatePickerComponent),
multi: true,
},
],
styleUrls: ['./date-picker.style.scss'],
})
export class DatePickerComponent
extends CommonFormControl<ConfigType, Dayjs>
implements OnInit
{
@Input()
clearable = true;
@Input()
clearText: string;
@Input()
format: string;
@Input()
showTime = false;
@Input()
type = DatePickerType.Day;
@Input()
size = ComponentSize.Medium;
@Input()
disabledDate: (date: Dayjs, type: DateNavRange) => boolean = () => false;
@Input()
disabledTime: DisabledTimeFn = () => null;
@Input()
minDate: Dayjs;
@Input()
maxDate: Dayjs;
@Input()
weekStartDay = 0;
@Input()
showFooter = true;
@Input()
footerTemplate: TemplateRef<unknown>;
@Input()
extraFooter: TemplateRef<unknown>;
@Input()
placeholder: string;
@Output()
openChange = new EventEmitter<boolean>();
value: Dayjs;
DatePickerType = DatePickerType;
ngOnInit() {
if (!this.format) {
this.format = this.getDefaultFormat(this.type);
this.cdr.markForCheck();
}
}
override valueIn(obj: ConfigType) {
return obj ? dayjs(obj) : null;
}
override writeValue(obj: Dayjs) {
super.writeValue(obj);
this.value = obj;
this.cdr.markForCheck();
}
private getDefaultFormat(type = DatePickerType.Day) {
return type === DatePickerType.Year
? 'YYYY'
: type === DatePickerType.Month
? 'YYYY-MM'
: this.showTime
? 'YYYY-MM-DD HH:mm:ss'
: 'YYYY-MM-DD';
}
clearValue() {
this.value = null;
this.emitValue(null);
}
}