Skip to content

Commit

Permalink
Merge pull request #11 from NGNOTFND/update-to-14
Browse files Browse the repository at this point in the history
Update to 14
  • Loading branch information
renanaragao authored Jul 24, 2023
2 parents 1b90c2b + 4680178 commit 0cbdb6f
Show file tree
Hide file tree
Showing 13 changed files with 10,557 additions and 10,904 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,4 @@ temp/

# End of https://www.toptal.com/developers/gitignore/api/node,visualstudiocode,angular

.angular/cache
.angular
4 changes: 2 additions & 2 deletions ng-typed-date-test/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<form #form="ngForm">
<!-- <input type="date" [(ngModelDate)]="periodo.dtInicio" [max]="periodo.dtFim" name="data" required />
<!-- <input type="date" [(ngModelDate)]="periodo.dtInicio" [max]="periodo.dtFim" name="dtInicio" required />
<br>
<input type="date" [(ngModelDate)]="periodo.dtFim" [min]="periodo.dtInicio" name="data" required />
<input type="date" [(ngModelDate)]="periodo.dtFim" [min]="periodo.dtInicio" name="dtFim" required />
<br> -->
<input type="datetime-local" [(ngModelDate)]="periodo.dtInicio" [max]="periodo.dtFim" name="dataInicio" required />
<br>
Expand Down
4 changes: 2 additions & 2 deletions ng-typed-date-test/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export class AppComponent {
today = '2021-5-20';

periodo = {
dtFim: new Date(),
dtInicio: new Date()
dtFim: Date,
dtInicio: Date
};

}
3 changes: 3 additions & 0 deletions ng-typed-date-test/src/app/ng-model-date.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ export class NgModelDateDirective extends NgModel implements OnInit, ControlValu
}

private isValidDate(value: Date | string) {
if(!value)
return false;

if (value instanceof Date)
return !isNaN(value.getTime());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,14 @@ export class NgModelDatetimeLocalDirective extends NgModel implements OnInit, Co

onChangeDate(value: string) {
this._ngModelDate = this.parseDateString(value);

this.control.setValue(this.formatDate(this._ngModelDate));
this.ngModelDateChange.emit(this._ngModelDate);
}

private parseDateString(date: string): Date {
if (!date)
return undefined;

date = date.replace('T', '-');
var parts = date.split('-');
var timeParts = parts[3].split(':');
Expand All @@ -151,6 +154,9 @@ export class NgModelDatetimeLocalDirective extends NgModel implements OnInit, Co
}

private isValidDate(value: Date | string) {
if (!value)
return false;

if (value instanceof Date)
return !isNaN(value.getTime());

Expand Down
3 changes: 1 addition & 2 deletions ng-typed-date/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,5 @@
}},
"cli": {
"analytics": false
},
"defaultProject": "ng-typed-date"
}
}
Loading

0 comments on commit 0cbdb6f

Please sign in to comment.