Skip to content

Commit

Permalink
fix: 🐛 Duration data if undefined issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ATHULKNAIR committed Oct 19, 2021
1 parent c253ebd commit 403cdd8
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/medblocks/duration/duration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ export default class MbDuration extends EhrElement {
@state() _state : {[period: string]: string | undefined} = {}

parsePeriod(period: string) {
const [periodPart, t] = period.split('T');
const p = periodPart.replace('P', '');
this._state.year = this.getPart(p, 'Y');
this._state.month = this.getPart(p, 'M');
this._state.week = this.getPart(p, 'W');
this._state.day = this.getPart(p, 'D');
if (t) {
this._state.hour = this.getPart(t, 'H');
this._state.minute = this.getPart(t, 'M');
this._state.second = this.getPart(t, 'S');
if(period){
const [periodPart, t] = period.split('T');
const p = periodPart.replace('P', '');
this._state.year = this.getPart(p, 'Y');
this._state.month = this.getPart(p, 'M');
this._state.week = this.getPart(p, 'W');
this._state.day = this.getPart(p, 'D');
if (t) {
this._state.hour = this.getPart(t, 'H');
this._state.minute = this.getPart(t, 'M');
this._state.second = this.getPart(t, 'S');
}
}
}

Expand Down

0 comments on commit 403cdd8

Please sign in to comment.