Skip to content

Commit

Permalink
Version 1.11.1: Bugfix in DateTime#add and DateTime#sub
Browse files Browse the repository at this point in the history
  • Loading branch information
rogierschouten committed Jan 8, 2015
1 parent b08dd44 commit 9e86aa0
Show file tree
Hide file tree
Showing 48 changed files with 472 additions and 406 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@ The version of the included IANA time zone database is 2014j.

## Changelog

### 1.11.1 (2015-01-08)
* Bugfix in DateTime#sub() and DateTime#add()

### 1.11.0 (2014-12-09)
* Add function startOfDay() to truncate a DateTime down to a date (00:00:00.000 on the same day).

Expand Down
13 changes: 10 additions & 3 deletions dist/timezonecomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,8 @@ var Duration = duration.Duration;
var javascript = require("./javascript");
var DateFunctions = javascript.DateFunctions;

var math = require("./math");

var timesource = require("./timesource");

var RealTimeSource = timesource.RealTimeSource;
Expand Down Expand Up @@ -1333,8 +1335,13 @@ var DateTime = (function () {
}
case 5 /* Month */: {
// keep the day-of-month the same (clamp to end-of-month)
targetYear = amount >= 0 ? (tm.year + Math.floor((tm.month - 1 + amount) / 12)) : (tm.year + Math.ceil((tm.month - 1 + amount) / 12));
targetMonth = 1 + (amount >= 0 ? Math.floor((tm.month - 1 + amount) % 12) : Math.ceil((tm.month - 1 + amount) % 12));
if (amount >= 0) {
targetYear = tm.year + Math.ceil((amount - (12 - tm.month)) / 12);
targetMonth = 1 + math.positiveModulo((tm.month - 1 + Math.floor(amount)), 12);
} else {
targetYear = tm.year + Math.floor((amount + (tm.month - 1)) / 12);
targetMonth = 1 + math.positiveModulo((tm.month - 1 + Math.ceil(amount)), 12);
}
targetDay = Math.min(tm.day, basics.daysInMonth(targetYear, targetMonth));
targetHours = tm.hour;
targetMinutes = tm.minute;
Expand Down Expand Up @@ -1593,7 +1600,7 @@ var DateTime = (function () {
exports.DateTime = DateTime;
//# sourceMappingURL=datetime.js.map

},{"./basics":1,"./duration":3,"./format":5,"./javascript":9,"./timesource":13,"./timezone":15,"assert":19,"source-map-support":38}],3:[function(require,module,exports){
},{"./basics":1,"./duration":3,"./format":5,"./javascript":9,"./math":10,"./timesource":13,"./timezone":15,"assert":19,"source-map-support":38}],3:[function(require,module,exports){
/**
* Copyright(c) 2014 Spirit IT BV
*
Expand Down
40 changes: 20 additions & 20 deletions doc/classes/_basics_.timestruct.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ <h3>constructor</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:626</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L626">basics.ts:626</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand Down Expand Up @@ -199,7 +199,7 @@ <h3>day</h3>
<div class="tsd-signature tsd-kind-icon">day<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:640</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L640">basics.ts:640</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -212,7 +212,7 @@ <h3>hour</h3>
<div class="tsd-signature tsd-kind-icon">hour<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:645</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L645">basics.ts:645</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -225,7 +225,7 @@ <h3>milli</h3>
<div class="tsd-signature tsd-kind-icon">milli<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:660</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L660">basics.ts:660</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -238,7 +238,7 @@ <h3>minute</h3>
<div class="tsd-signature tsd-kind-icon">minute<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:650</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L650">basics.ts:650</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -251,7 +251,7 @@ <h3>month</h3>
<div class="tsd-signature tsd-kind-icon">month<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:635</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L635">basics.ts:635</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -264,7 +264,7 @@ <h3>second</h3>
<div class="tsd-signature tsd-kind-icon">second<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:655</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L655">basics.ts:655</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -277,7 +277,7 @@ <h3>year</h3>
<div class="tsd-signature tsd-kind-icon">year<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:630</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L630">basics.ts:630</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -295,7 +295,7 @@ <h3>clone</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:718</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L718">basics.ts:718</a></li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <a href="_basics_.timestruct.html" class="tsd-signature-type">TimeStruct</a>
Expand All @@ -311,7 +311,7 @@ <h3>equals</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:701</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L701">basics.ts:701</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -337,7 +337,7 @@ <h3><span class="tsd-flag ts-flagstatic">static</span> from<wbr>Date</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:487</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L487">basics.ts:487</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand Down Expand Up @@ -376,7 +376,7 @@ <h3><span class="tsd-flag ts-flagstatic">static</span> from<wbr>String</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:500</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L500">basics.ts:500</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -402,7 +402,7 @@ <h3><span class="tsd-flag ts-flagstatic">static</span> from<wbr>Unix</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:477</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L477">basics.ts:477</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -428,7 +428,7 @@ <h3>inspect</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:739</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L739">basics.ts:739</a></li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span>
Expand All @@ -444,7 +444,7 @@ <h3>less<wbr>Than</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:714</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L714">basics.ts:714</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -470,7 +470,7 @@ <h3>to<wbr>String</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:729</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L729">basics.ts:729</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -490,7 +490,7 @@ <h3>to<wbr>Unix<wbr>NoLeap<wbr>Secs</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:693</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L693">basics.ts:693</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -511,7 +511,7 @@ <h3>validate</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:668</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L668">basics.ts:668</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand All @@ -531,7 +531,7 @@ <h3>value<wbr>Of</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:722</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L722">basics.ts:722</a></li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span>
Expand All @@ -547,7 +547,7 @@ <h3>year<wbr>Day</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in basics.ts:684</li>
<li>Defined in <a href="https://github.com/SpiritIT/timezonecomplete/blob/master/lib/basics.ts#L684">basics.ts:684</a></li>
</ul>
</aside> <div class="tsd-comment tsd-typography">
<div class="lead">
Expand Down
Loading

0 comments on commit 9e86aa0

Please sign in to comment.