Skip to content

Commit

Permalink
v1.24.1: bugfix in parsing dates with zeroes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rogier Schouten committed Nov 27, 2015
1 parent 74968d2 commit aaa6632
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 20 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@ The version of the included IANA time zone database is 2015g.

## Changelog

### 1.24.1 (2015-11-27)
* Bugfix parsing times with zeroes.

### 1.24.0 (2015-11-05)
* Add new DateTime constructor that accepts a date string and a format string to parse dates in a given format
* Add new static method DateTime.parse() that does the same.
Expand Down
2 changes: 1 addition & 1 deletion dist/timezonecomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -3151,7 +3151,7 @@ function stripNumber(s) {
result.remaining = result.remaining.substr(1);
}
// remove leading zeroes
while (numberString.charAt(0) === "0") {
while (numberString.charAt(0) === "0" && numberString.length > 1) {
numberString = numberString.substr(1);
}
result.n = parseInt(numberString, 10);
Expand Down
10 changes: 7 additions & 3 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,10 @@ <h3 id="does-timezonecomplete-handle-leap-seconds-">Does timezonecomplete handle
<h2 id="current-tz-database-version-">Current TZ database version:</h2>
<p>The version of the included IANA time zone database is 2015g.</p>
<h2 id="changelog">Changelog</h2>
<h3 id="1-24-1-2015-11-27-">1.24.1 (2015-11-27)</h3>
<ul>
<li>Bugfix parsing times with zeroes.</li>
</ul>
<h3 id="1-24-0-2015-11-05-">1.24.0 (2015-11-05)</h3>
<ul>
<li>Add new DateTime constructor that accepts a date string and a format string to parse dates in a given format</li>
Expand Down Expand Up @@ -985,9 +989,9 @@ <h3 id="1-0-0-2014-06-26-">1.0.0 (2014-06-26)</h3>
</ul>
<h2 id="contributors">Contributors</h2>
<ul>
<li>Rogier Schouten <a href="&#109;&#97;&#x69;&#x6c;&#116;&#x6f;&#x3a;&#x72;&#46;&#115;&#99;&#104;&#x6f;&#117;&#116;&#x65;&#x6e;&#64;&#115;&#112;&#x69;&#114;&#105;&#116;&#105;&#116;&#46;&#99;&#111;&#109;">&#x72;&#46;&#115;&#99;&#104;&#x6f;&#117;&#116;&#x65;&#x6e;&#64;&#115;&#112;&#x69;&#114;&#105;&#116;&#105;&#116;&#46;&#99;&#111;&#109;</a></li>
<li>Daan Wissing <a href="&#109;&#x61;&#x69;&#x6c;&#116;&#x6f;&#x3a;&#100;&#x2e;&#x77;&#x69;&#115;&#x73;&#105;&#110;&#x67;&#64;&#115;&#x70;&#x69;&#x72;&#x69;&#116;&#x69;&#116;&#46;&#99;&#x6f;&#109;">&#100;&#x2e;&#x77;&#x69;&#115;&#x73;&#105;&#110;&#x67;&#64;&#115;&#x70;&#x69;&#x72;&#x69;&#116;&#x69;&#116;&#46;&#99;&#x6f;&#109;</a></li>
<li>Peter Kooijmans <a href="&#109;&#97;&#x69;&#108;&#116;&#x6f;&#58;&#112;&#x2e;&#107;&#111;&#111;&#x69;&#106;&#x6d;&#97;&#110;&#115;&#64;&#115;&#112;&#105;&#x72;&#105;&#x74;&#105;&#116;&#x2e;&#x63;&#111;&#109;">&#112;&#x2e;&#107;&#111;&#111;&#x69;&#106;&#x6d;&#97;&#110;&#115;&#64;&#115;&#112;&#105;&#x72;&#105;&#x74;&#105;&#116;&#x2e;&#x63;&#111;&#109;</a></li>
<li>Rogier Schouten <a href="&#x6d;&#x61;&#105;&#108;&#x74;&#111;&#58;&#x72;&#x2e;&#x73;&#99;&#104;&#x6f;&#x75;&#116;&#101;&#110;&#x40;&#115;&#112;&#x69;&#x72;&#x69;&#116;&#105;&#x74;&#x2e;&#99;&#111;&#109;">&#x72;&#x2e;&#x73;&#99;&#104;&#x6f;&#x75;&#116;&#101;&#110;&#x40;&#115;&#112;&#x69;&#x72;&#x69;&#116;&#105;&#x74;&#x2e;&#99;&#111;&#109;</a></li>
<li>Daan Wissing <a href="&#109;&#97;&#105;&#x6c;&#116;&#x6f;&#x3a;&#x64;&#46;&#119;&#105;&#x73;&#x73;&#x69;&#x6e;&#103;&#x40;&#115;&#112;&#x69;&#114;&#105;&#116;&#105;&#116;&#x2e;&#99;&#111;&#109;">&#x64;&#46;&#119;&#105;&#x73;&#x73;&#x69;&#x6e;&#103;&#x40;&#115;&#112;&#x69;&#114;&#105;&#116;&#105;&#116;&#x2e;&#99;&#111;&#109;</a></li>
<li>Peter Kooijmans <a href="&#x6d;&#x61;&#105;&#x6c;&#116;&#111;&#x3a;&#112;&#46;&#107;&#111;&#111;&#105;&#x6a;&#109;&#97;&#x6e;&#115;&#x40;&#115;&#112;&#105;&#114;&#105;&#116;&#x69;&#x74;&#46;&#99;&#x6f;&#109;">&#112;&#46;&#107;&#111;&#111;&#105;&#x6a;&#109;&#97;&#x6e;&#115;&#x40;&#115;&#112;&#105;&#114;&#105;&#116;&#x69;&#x74;&#46;&#99;&#x6f;&#109;</a></li>
</ul>
<h2 id="license">License</h2>
<p>MIT</p>
Expand Down
4 changes: 2 additions & 2 deletions doc/interfaces/_parse_.awaretimestruct.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h3>time</h3>
<div class="tsd-signature tsd-kind-icon">time<span class="tsd-signature-symbol">:</span> <a href="../classes/_basics_.timestruct.html" class="tsd-signature-type">TimeStruct</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in parse.ts:30</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/parse.ts#L30">parse.ts:30</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -122,7 +122,7 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> zone</h3>
<div class="tsd-signature tsd-kind-icon">zone<span class="tsd-signature-symbol">:</span> <a href="../classes/_timezone_.timezone.html" class="tsd-signature-type">TimeZone</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in parse.ts:34</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/parse.ts#L34">parse.ts:34</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down
4 changes: 2 additions & 2 deletions doc/interfaces/_parse_.parsenumberresult.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ <h3>n</h3>
<div class="tsd-signature tsd-kind-icon">n<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in parse.ts:38</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/parse.ts#L38">parse.ts:38</a></li>
</ul>
</aside>
</section>
Expand All @@ -110,7 +110,7 @@ <h3>remaining</h3>
<div class="tsd-signature tsd-kind-icon">remaining<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in parse.ts:39</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/parse.ts#L39">parse.ts:39</a></li>
</ul>
</aside>
</section>
Expand Down
4 changes: 2 additions & 2 deletions doc/interfaces/_parse_.parsezoneresult.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ <h3>remaining</h3>
<div class="tsd-signature tsd-kind-icon">remaining<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in parse.ts:44</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/parse.ts#L44">parse.ts:44</a></li>
</ul>
</aside>
</section>
Expand All @@ -110,7 +110,7 @@ <h3>zone</h3>
<div class="tsd-signature tsd-kind-icon">zone<span class="tsd-signature-symbol">:</span> <a href="../classes/_timezone_.timezone.html" class="tsd-signature-type">TimeZone</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in parse.ts:43</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/parse.ts#L43">parse.ts:43</a></li>
</ul>
</aside>
</section>
Expand Down
10 changes: 5 additions & 5 deletions doc/modules/_parse_.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ <h3>WHITESPACE</h3>
<div class="tsd-signature tsd-kind-icon">WHITESPACE<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Array</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">&gt;</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in parse.ts:172</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/parse.ts#L172">parse.ts:172</a></li>
</ul>
</aside>
</section>
Expand All @@ -122,7 +122,7 @@ <h3>parse</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in parse.ts:54</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/parse.ts#L54">parse.ts:54</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -163,7 +163,7 @@ <h3>strip<wbr>Number</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in parse.ts:151</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/parse.ts#L151">parse.ts:151</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -186,7 +186,7 @@ <h3>strip<wbr>Raw</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in parse.ts:191</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/parse.ts#L191">parse.ts:191</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -212,7 +212,7 @@ <h3>strip<wbr>Zone</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in parse.ts:174</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/parse.ts#L174">parse.ts:174</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand Down
4 changes: 2 additions & 2 deletions lib/parse.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function stripNumber(s: string): ParseNumberResult {
result.remaining = result.remaining.substr(1);
}
// remove leading zeroes
while (numberString.charAt(0) === "0") {
while (numberString.charAt(0) === "0" && numberString.length > 1) {
numberString = numberString.substr(1);
}
result.n = parseInt(numberString, 10);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "timezonecomplete",
"version": "1.24.0",
"version": "1.24.1",
"description": "DateTime, TimeZone, Duration and Period library aimed at providing a consistent and complete date-time interface, away from the original JavaScript Date class.",
"keywords": [
"Date",
Expand Down
13 changes: 12 additions & 1 deletion test/test-datetime.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions test/test-datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,17 @@ describe("DateTime", (): void => {
expect(d.millisecond()).to.equal(233);
expect(d.zone().identical(TimeZone.zone("America/Chicago"))).to.equal(true);
});
it("should parse date with zeroes", (): void => {
var d = new DateTime("3/2/2015 06:00:00.000 America/Chicago", "MM/dd/yyyy HH:mm:ss.SSS zzzz");
expect(d.year()).to.equal(2015);
expect(d.month()).to.equal(3);
expect(d.day()).to.equal(2);
expect(d.hour()).to.equal(6);
expect(d.minute()).to.equal(0);
expect(d.second()).to.equal(0);
expect(d.millisecond()).to.equal(0);
expect(d.zone().identical(TimeZone.zone("America/Chicago"))).to.equal(true);
});
});

describe("constructor(date: Date, dateKind: DateFunctions, timeZone?: TimeZone)", (): void => {
Expand Down

0 comments on commit aaa6632

Please sign in to comment.