Ajout d'un format custom de la date
This commit is contained in:
@@ -11,10 +11,32 @@ import { JumpService } from "../../services/jump.service";
|
||||
import { JumpTypeService } from "../../services/jump-type.service";
|
||||
import { GearService } from "../../services/gear.service";
|
||||
|
||||
import { formatDate } from '@angular/common';
|
||||
import { DateAdapter, MAT_DATE_FORMATS, NativeDateAdapter } from "@angular/material/core";
|
||||
|
||||
export const PICK_FORMATS = {
|
||||
parse: { dateInput: 'yy MM dd' },
|
||||
display: {
|
||||
dateInput: 'yyyy-MM-dd',
|
||||
monthYearLabel: 'yyyy MMM',
|
||||
dateA11yLabel: 'yyyy MM dd',
|
||||
monthYearA11yLabel: 'yyyy MMMM',
|
||||
}
|
||||
};
|
||||
class PickDateAdapter extends NativeDateAdapter {
|
||||
format(date: Date, displayFormat: Object): string {
|
||||
return formatDate(date, displayFormat.toString(), "en");
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: "app-new-jump",
|
||||
templateUrl: "./new-jump.component.html",
|
||||
styleUrls: ["./new-jump.component.css"]
|
||||
styleUrls: ["./new-jump.component.css"],
|
||||
providers: [
|
||||
{ provide: DateAdapter, useClass: PickDateAdapter },
|
||||
{ provide: MAT_DATE_FORMATS, useValue: PICK_FORMATS }
|
||||
]
|
||||
})
|
||||
export class NewJumpComponent implements OnInit {
|
||||
public beginDate: Date;
|
||||
|
||||
Reference in New Issue
Block a user