Skip to content

Commit

Permalink
Fix issues related with wrong working with dates.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxShoshin committed Feb 21, 2018
1 parent 1a61d9c commit 6b839fa
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"build": "ng build --prod --base-href=/TalkPad/",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
Expand Down
4 changes: 4 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export class AppComponent implements DoCheck {
const stored = localStorage.getItem(AppComponent._storageKey);
if (stored) {
this.meetup = Object.assign(MeetupFactory.createMeetup(), JSON.parse(stored));
this.meetup.sessions.forEach(session =>{
session.startTime = new Date(session.startTime);
session.endTime = new Date(session.endTime);
});
}
else {
this.meetup = MeetupFactory.createMeetup();
Expand Down
8 changes: 4 additions & 4 deletions src/app/session-editor/session-editor.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ <h2>Доклад</h2>
[ngModel]="session.startTime | date:'yyyy-MM-dd'"
(ngModelChange)="setDates($event)"/>
<label class="mx-2" for="startTime" >От:</label>
<input type="time" class="form-control" required id="startTime"
<input type="time" class="form-control" required id="startTime" #startTimeInput
[ngModel]="session.startTime | date:'HH:mm'"
(ngModelChange)="setTimeFor(session.startTime, $event) "/>
(ngModelChange)="setTimeFor(session.startTime, startTimeInput.valueAsDate) "/>
<label class="mx-2" for="endTime" >До:</label>
<input type="time" class="form-control" required id="endTime"
<input type="time" class="form-control" required id="endTime" #endTimeInput
[ngModel]="session.endTime | date:'HH:mm'"
(ngModelChange)="setTimeFor(session.endTime, $event) "/>
(ngModelChange)="setTimeFor(session.endTime, endTimeInput.valueAsDate) "/>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/app/session-editor/session-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ export class SessionEditorComponent {

setTimeFor(dateTime: Date, timeStr: string) {
const time = new Date(timeStr);
dateTime.setHours(time.getHours(), time.getMinutes(), 0);
dateTime.setHours(time.getUTCHours(), time.getUTCMinutes(), 0);
}
}
10 changes: 8 additions & 2 deletions src/app/xml-encode.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ export class XmlEncodePipe implements PipeTransform {
}

transform(value: string): string {
if (value) {
return value.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;');
}

return this._santizer.sanitize(SecurityContext.HTML, value);
return value;
}

}

0 comments on commit 6b839fa

Please sign in to comment.