Skip to content

Commit

Permalink
get rid of utc precision
Browse files Browse the repository at this point in the history
  • Loading branch information
au2 committed Nov 23, 2014
1 parent 9c6fcdd commit 890d357
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 33 deletions.
13 changes: 4 additions & 9 deletions dist/blue-button-xml.js
Expand Up @@ -174,16 +174,11 @@ exports.hl7ToPrecision = (function () {

return function (hl7DateTime) {
var d = parseHl7(hl7DateTime);
if (d.zone) {
var m = dateArrayZoneToMoment(d);
return 'utc:' + m.zone();
} else {
var n = d.dateArray.length;
if (n > 3) {
n = 3; // ignore time when no zone
}
return (n < precisions.length) ? precisions[n] : null;
var n = d.dateArray.length;
if ((!d.zone) && (n > 3)) {
n = 3; // ignore time when no zone
}
return (n < precisions.length) ? precisions[n] : null;
};
})();

Expand Down
19 changes: 7 additions & 12 deletions dist/mocha_tests.js
Expand Up @@ -183,16 +183,11 @@ exports.hl7ToPrecision = (function () {

return function (hl7DateTime) {
var d = parseHl7(hl7DateTime);
if (d.zone) {
var m = dateArrayZoneToMoment(d);
return 'utc:' + m.zone();
} else {
var n = d.dateArray.length;
if (n > 3) {
n = 3; // ignore time when no zone
}
return (n < precisions.length) ? precisions[n] : null;
var n = d.dateArray.length;
if ((!d.zone) && (n > 3)) {
n = 3; // ignore time when no zone
}
return (n < precisions.length) ? precisions[n] : null;
};
})();

Expand Down Expand Up @@ -12308,15 +12303,15 @@ describe('hl7 to/from iso8601 date/time conversion', function () {
}, {
hl7: '20120915211442+0200',
iso8601: "2012-09-15T19:14:42.000Z",
precision: 'utc:-120'
precision: 'second'
}, {
hl7: '20120915211442.123',
iso8601: "2012-09-15T00:00:00.000Z",
precision: 'day'
}, {
hl7: '20120915211442.123-0500',
iso8601: "2012-09-16T02:14:42.123Z",
precision: 'utc:300'
precision: 'subsecond'
}];

testCases.forEach(function (testCase) {
Expand Down Expand Up @@ -13090,7 +13085,7 @@ describe('processor', function () {
expect(r.data.p[4]).to.equal("day");
expect(r.data.p[5]).to.equal("day");
expect(r.data.p[6]).to.equal("day");
expect(r.data.p[7]).to.equal("utc:-130");
expect(r.data.p[7]).to.equal("subsecond");
});
});

Expand Down
13 changes: 4 additions & 9 deletions lib/bbUtil.js
Expand Up @@ -93,15 +93,10 @@ exports.hl7ToPrecision = (function () {

return function (hl7DateTime) {
var d = parseHl7(hl7DateTime);
if (d.zone) {
var m = dateArrayZoneToMoment(d);
return 'utc:' + m.zone();
} else {
var n = d.dateArray.length;
if (n > 3) {
n = 3; // ignore time when no zone
}
return (n < precisions.length) ? precisions[n] : null;
var n = d.dateArray.length;
if ((!d.zone) && (n > 3)) {
n = 3; // ignore time when no zone
}
return (n < precisions.length) ? precisions[n] : null;
};
})();
4 changes: 2 additions & 2 deletions test/test-bbUtil.js
Expand Up @@ -34,15 +34,15 @@ describe('hl7 to/from iso8601 date/time conversion', function () {
}, {
hl7: '20120915211442+0200',
iso8601: "2012-09-15T19:14:42.000Z",
precision: 'utc:-120'
precision: 'second'
}, {
hl7: '20120915211442.123',
iso8601: "2012-09-15T00:00:00.000Z",
precision: 'day'
}, {
hl7: '20120915211442.123-0500',
iso8601: "2012-09-16T02:14:42.123Z",
precision: 'utc:300'
precision: 'subsecond'
}];

testCases.forEach(function (testCase) {
Expand Down
2 changes: 1 addition & 1 deletion test/test-processor.js
Expand Up @@ -58,6 +58,6 @@ describe('processor', function () {
expect(r.data.p[4]).to.equal("day");
expect(r.data.p[5]).to.equal("day");
expect(r.data.p[6]).to.equal("day");
expect(r.data.p[7]).to.equal("utc:-130");
expect(r.data.p[7]).to.equal("subsecond");
});
});

0 comments on commit 890d357

Please sign in to comment.