Skip to content

Commit

Permalink
Release 1.13.2: Allow "without DST" suffix on time zone names.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rogier Schouten committed Mar 11, 2015
1 parent 52eb27b commit 9338d80
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 37 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ The version of the included IANA time zone database is 2015a.

## Changelog

### 1.13.2 (2015-03-11)
* Allow "without DST" suffix in time zone name.

### 1.13.1 (2015-03-10)
* Check time zone name in TimeZone constructor.

Expand Down
9 changes: 7 additions & 2 deletions dist/timezonecomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -3236,11 +3236,16 @@ var TimeZone = (function () {
switch (typeof (a)) {
case "string":
{
if (a.trim().length === 0) {
var s = a;
if (s.trim().length === 0) {
return null; // no time zone
}
else {
name = TimeZone._normalizeString(a);
if (s.indexOf("without DST") >= 0) {
dst = false;
s = s.slice(0, s.indexOf("without DST") - 1);
}
name = TimeZone._normalizeString(s);
}
}
break;
Expand Down
52 changes: 27 additions & 25 deletions doc/classes/_timezone_.timezone.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ <h3>constructor</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:208</li>
<li>Defined in timezone.ts:215</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -180,7 +180,7 @@ <h3><span class="tsd-flag ts-flagprivate">private</span> <span class="tsd-flag t
<div class="tsd-signature tsd-kind-icon">_cache<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Object</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:629</li>
<li>Defined in timezone.ts:636</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -197,7 +197,7 @@ <h3>_cache index signature</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:629</li>
<li>Defined in timezone.ts:636</li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand Down Expand Up @@ -288,7 +288,7 @@ <h3><span class="tsd-flag ts-flagprivate">private</span> <span class="tsd-flag t
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:636</li>
<li>Defined in timezone.ts:643</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -330,7 +330,7 @@ <h3><span class="tsd-flag ts-flagprivate">private</span> <span class="tsd-flag t
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:668</li>
<li>Defined in timezone.ts:675</li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -354,7 +354,7 @@ <h3><span class="tsd-flag ts-flagprivate">private</span> <span class="tsd-flag t
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:651</li>
<li>Defined in timezone.ts:658</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -384,7 +384,7 @@ <h3>abbreviation<wbr>For<wbr>Utc</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:515</li>
<li>Defined in timezone.ts:522</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -475,7 +475,7 @@ <h3>dst</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:231</li>
<li>Defined in timezone.ts:238</li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns
Expand All @@ -493,7 +493,7 @@ <h3>equals</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:246</li>
<li>Defined in timezone.ts:253</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -523,7 +523,7 @@ <h3>has<wbr>Dst</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:306</li>
<li>Defined in timezone.ts:313</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -546,7 +546,7 @@ <h3>identical</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:269</li>
<li>Defined in timezone.ts:276</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -575,7 +575,7 @@ <h3>inspect</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:584</li>
<li>Defined in timezone.ts:591</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -598,7 +598,7 @@ <h3>is<wbr>Utc</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:287</li>
<li>Defined in timezone.ts:294</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -621,7 +621,7 @@ <h3>kind</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:238</li>
<li>Defined in timezone.ts:245</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -669,7 +669,7 @@ <h3>name</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:227</li>
<li>Defined in timezone.ts:234</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -694,7 +694,7 @@ <h3>normalize<wbr>Zone<wbr>Time</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:557</li>
<li>Defined in timezone.ts:564</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -741,7 +741,7 @@ <h3>offset<wbr>For<wbr>Utc</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:335</li>
<li>Defined in timezone.ts:342</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -824,7 +824,7 @@ <h3>offset<wbr>For<wbr>Utc<wbr>Date</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:428</li>
<li>Defined in timezone.ts:435</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -858,7 +858,7 @@ <h3>offset<wbr>For<wbr>Zone</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:382</li>
<li>Defined in timezone.ts:389</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -941,7 +941,7 @@ <h3>offset<wbr>For<wbr>Zone<wbr>Date</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:469</li>
<li>Defined in timezone.ts:476</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -975,7 +975,7 @@ <h3><span class="tsd-flag ts-flagstatic">static</span> offset<wbr>ToString</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:593</li>
<li>Defined in timezone.ts:600</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -1010,7 +1010,7 @@ <h3><span class="tsd-flag ts-flagstatic">static</span> string<wbr>ToOffset</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:605</li>
<li>Defined in timezone.ts:612</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -1045,7 +1045,7 @@ <h3>to<wbr>String</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:571</li>
<li>Defined in timezone.ts:578</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -1093,7 +1093,7 @@ <h3><span class="tsd-flag ts-flagstatic">static</span> zone</h3>
<ul class="tsd-descriptions">
<li class="tsd-description"><aside class="tsd-sources">
<ul>
<li>Defined in timezone.ts:171</li>
<li>Defined in timezone.ts:173</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -1111,7 +1111,9 @@ <h5>s: <span class="tsd-signature-type">string</span></h5>
&quot;localtime&quot; for local time,
a TZ database time zone name (e.g. Europe/Amsterdam),
or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see:
<a href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">https://en.wikipedia.org/wiki/List_of_tz_database_time_zones</a></p>
<a href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">https://en.wikipedia.org/wiki/List_of_tz_database_time_zones</a>
TZ database zone name may be suffixed with &quot; without DST&quot; to indicate no DST should be applied.
In that case, the dst parameter is ignored.</p>
</div>
</li>
<li>
Expand Down
10 changes: 7 additions & 3 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,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 2015a.</p>
<h2 id="changelog">Changelog</h2>
<h3 id="1-13-2-2015-03-11-">1.13.2 (2015-03-11)</h3>
<ul>
<li>Allow &quot;without DST&quot; suffix in time zone name.</li>
</ul>
<h3 id="1-13-1-2015-03-10-">1.13.1 (2015-03-10)</h3>
<ul>
<li>Check time zone name in TimeZone constructor.</li>
Expand Down Expand Up @@ -750,9 +754,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;&#105;&#108;&#x74;&#111;&#x3a;&#114;&#46;&#x73;&#99;&#104;&#x6f;&#117;&#116;&#x65;&#110;&#x40;&#115;&#x70;&#x69;&#114;&#105;&#x74;&#x69;&#116;&#x2e;&#x63;&#x6f;&#109;">&#114;&#46;&#x73;&#99;&#104;&#x6f;&#117;&#116;&#x65;&#110;&#x40;&#115;&#x70;&#x69;&#114;&#105;&#x74;&#x69;&#116;&#x2e;&#x63;&#x6f;&#109;</a></li>
<li>Daan Wissing <a href="&#109;&#97;&#x69;&#x6c;&#x74;&#111;&#58;&#100;&#46;&#119;&#105;&#115;&#x73;&#x69;&#x6e;&#103;&#x40;&#x73;&#112;&#105;&#x72;&#105;&#116;&#105;&#x74;&#x2e;&#99;&#x6f;&#109;">&#100;&#46;&#119;&#105;&#115;&#x73;&#x69;&#x6e;&#103;&#x40;&#x73;&#112;&#105;&#x72;&#105;&#116;&#105;&#x74;&#x2e;&#99;&#x6f;&#109;</a></li>
<li>Peter Kooijmans <a href="&#x6d;&#x61;&#105;&#108;&#116;&#x6f;&#58;&#112;&#x2e;&#107;&#111;&#111;&#105;&#106;&#x6d;&#97;&#x6e;&#x73;&#x40;&#x73;&#112;&#x69;&#x72;&#105;&#x74;&#105;&#x74;&#x2e;&#x63;&#111;&#109;">&#112;&#x2e;&#107;&#111;&#111;&#105;&#106;&#x6d;&#97;&#x6e;&#x73;&#x40;&#x73;&#112;&#x69;&#x72;&#105;&#x74;&#105;&#x74;&#x2e;&#x63;&#111;&#109;</a></li>
<li>Rogier Schouten <a href="&#109;&#97;&#x69;&#x6c;&#116;&#111;&#58;&#x72;&#x2e;&#x73;&#99;&#x68;&#x6f;&#x75;&#x74;&#x65;&#110;&#x40;&#x73;&#112;&#x69;&#114;&#x69;&#116;&#105;&#x74;&#46;&#99;&#x6f;&#x6d;">&#x72;&#x2e;&#x73;&#99;&#x68;&#x6f;&#x75;&#x74;&#x65;&#110;&#x40;&#x73;&#112;&#x69;&#114;&#x69;&#116;&#105;&#x74;&#46;&#99;&#x6f;&#x6d;</a></li>
<li>Daan Wissing <a href="&#109;&#97;&#105;&#108;&#x74;&#x6f;&#x3a;&#x64;&#46;&#x77;&#x69;&#115;&#115;&#x69;&#110;&#103;&#64;&#x73;&#x70;&#105;&#x72;&#105;&#x74;&#105;&#116;&#x2e;&#99;&#111;&#109;">&#x64;&#46;&#x77;&#x69;&#115;&#115;&#x69;&#110;&#103;&#64;&#x73;&#x70;&#105;&#x72;&#105;&#x74;&#105;&#116;&#x2e;&#99;&#111;&#109;</a></li>
<li>Peter Kooijmans <a href="&#109;&#97;&#x69;&#108;&#x74;&#x6f;&#58;&#112;&#46;&#107;&#111;&#x6f;&#x69;&#x6a;&#109;&#x61;&#110;&#x73;&#x40;&#x73;&#x70;&#x69;&#114;&#x69;&#x74;&#x69;&#x74;&#x2e;&#x63;&#x6f;&#x6d;">&#112;&#46;&#107;&#111;&#x6f;&#x69;&#x6a;&#109;&#x61;&#110;&#x73;&#x40;&#x73;&#x70;&#x69;&#114;&#x69;&#x74;&#x69;&#x74;&#x2e;&#x63;&#x6f;&#x6d;</a></li>
</ul>
<h2 id="license">License</h2>
<p>MIT</p>
Expand Down
11 changes: 8 additions & 3 deletions lib/timezone.js

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions lib/timezone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ export class TimeZone {
* a TZ database time zone name (e.g. Europe/Amsterdam),
* or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see:
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
* TZ database zone name may be suffixed with " without DST" to indicate no DST should be applied.
* In that case, the dst parameter is ignored.
* @param dst Optional, default true: adhere to Daylight Saving Time if applicable. Note for
* "localtime", timezonecomplete will adhere to the computer settings, the DST flag
* does not have any effect.
Expand All @@ -178,10 +180,15 @@ export class TimeZone {
var name = "";
switch (typeof (a)) {
case "string": {
if ((<string>a).trim().length === 0) {
var s = <string>a;
if (s.trim().length === 0) {
return null; // no time zone
} else {
name = TimeZone._normalizeString(<string>a);
if (s.indexOf("without DST") >= 0) {
dst = false;
s = s.slice(0, s.indexOf("without DST") - 1);
}
name = TimeZone._normalizeString(s);
}
} break;
case "number": {
Expand Down
2 changes: 2 additions & 0 deletions lib/timezonecomplete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,8 @@ declare module '__timezonecomplete/timezone' {
* a TZ database time zone name (e.g. Europe/Amsterdam),
* or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see:
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
* TZ database zone name may be suffixed with " without DST" to indicate no DST should be applied.
* In that case, the dst parameter is ignored.
* @param dst Optional, default true: adhere to Daylight Saving Time if applicable. Note for
* "localtime", timezonecomplete will adhere to the computer settings, the DST flag
* does not have any effect.
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.13.1",
"version": "1.13.2",
"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
8 changes: 7 additions & 1 deletion test/test-timezone.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions test/test-timezone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ describe("TimeZone", (): void => {
var t: TimeZone = TimeZone.zone("Europe/Amsterdam", false);
expect(t.offsetForZone(2014, 7, 1, 1, 2, 3, 4)).to.equal(60);
});
it("should not apply DST if asked with string suffix 'without DST'", (): void => {
var t: TimeZone = TimeZone.zone("Europe/Amsterdam without DST", true);
var u: TimeZone = TimeZone.zone("Europe/Amsterdam without DST", false);
expect(t).to.equal(u);
expect(t.dst()).to.equal(false);
});
it("should return a time zone for local time", (): void => {
var t: TimeZone = TimeZone.zone("localtime");
expect(t.equals(TimeZone.local())).to.equal(true);
Expand Down

0 comments on commit 9338d80

Please sign in to comment.