Skip to content

Commit

Permalink
v4.0.1: enable stand-alone use and add example
Browse files Browse the repository at this point in the history
  • Loading branch information
Rogier Schouten committed Oct 16, 2016
1 parent dd750ee commit 832a9e4
Show file tree
Hide file tree
Showing 8 changed files with 6,117 additions and 63 deletions.
10 changes: 6 additions & 4 deletions browserify-umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ var browserify = require("browserify");
var fs = require("fs");
var glob = require("glob");
var mkdirp = require("mkdirp");
var Umd = require("browserify-umdify");
var util = require("util");

mkdirp.sync("./temp");

var exampleOutFile = "./examples/browser-amd-requirejs/timezonecomplete.js";
var exampleOut = fs.createWriteStream(exampleOutFile, { encoding: "utf-8", flags: "w"})
var example2OutFile = "./examples/browser-stand-alone/timezonecomplete.js";
var example2Out = fs.createWriteStream(exampleOutFile, { encoding: "utf-8", flags: "w"})

var packageJson = require("./package.json");
var distOutFileVersioned = util.format("./temp/timezonecomplete.%s.js", packageJson.version);
Expand All @@ -20,13 +21,14 @@ var distOutUnversioned = fs.createWriteStream(distOutFileUnversioned, { encoding

var bundled = browserify({
extensions: [".js", ".json"],
debug: true
debug: true,
standalone: "tc"
})
.require("./dist/lib/index.js", { expose: "timezonecomplete" })
.bundle()
.pipe(new Umd());
.bundle();

bundled.pipe(exampleOut);
bundled.pipe(example2Out);
bundled.pipe(distOutVersioned);
bundled.pipe(distOutUnversioned);

Expand Down
27 changes: 3 additions & 24 deletions dist/timezonecomplete.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions dist/timezonecomplete.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

# Changelog

### 4.0.1 (2016-10-16)
* Fix for stand-alone use of timezonecomplete browser bundles
* Add stand-alone use example

### 4.0.0 (2016-10-15)
* Performance improvements, with a few minor breaking changes as a result

Expand Down
27 changes: 3 additions & 24 deletions examples/browser-amd-requirejs/timezonecomplete.js

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions examples/browser-stand-alone/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Timezonecomplete Browser Example</title>
<script src="./timezonecomplete.js"></script>
<script>
function doIt() {
var utc = tc.nowUtc();
var local = utc.toZone(tc.zone('localtime'));
var diff = local.toZone(null).diff(utc.toZone(null));
var hourDiff = tc.hours(diff.hours());

document.getElementById('utc').textContent = utc.format('dd-MMM-yyyy HH:mm:ss');
document.getElementById('local').textContent = local.format('dd-MMM-yyyy HH:mm:ss');
document.getElementById('diff').textContent = hourDiff.toString();
}
</script>
</head>
<body onLoad="doIt()">
<p>
The current UTC time is:&nbsp;
<span id="utc"></div>
</p>

<p>
The current local time is:&nbsp;
<span id="local"></div>
</p>
<p>
The difference is:&nbsp;
<span id="diff"></div>
</p>
</body>
</html>
Loading

0 comments on commit 832a9e4

Please sign in to comment.