Skip to content

Commit fef0bf8

Browse files
authored
Security dependency updates. (#15)
* New hybrid ES6/ES2018 Angular-friendly package design. * New DateTime.get() method, corresponding to DateTime.set(). * Fixed problem with "small" timezone definitions getting optimized away.
1 parent 4524c4f commit fef0bf8

21 files changed

Lines changed: 3019 additions & 2834 deletions

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/img
99
/.nyc_output
1010
*.js.map
11+
!/dist/**/*.js.map
1112
*.spec.d.ts
1213
*.spec.js
1314
/webpack.config.cjs

README.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,32 @@ Two alternate large timezone definition sets, of approximately 280K each, are av
102102

103103
...or...
104104

105-
`const { ttime, DateTime, Timezone`...`} = require('@tubular/time/es6'); // CommonJS`
105+
`const { ttime, DateTime, Timezone`...`} = require('@tubular/time/cjs'); // CommonJS`
106106

107-
Documentation examples will assume **@tubular/time** has been imported as above. You can also require `'@tubular/time/es5'` for ES5-compatible code.
107+
Documentation examples will assume **@tubular/time** has been imported as above.
108108

109109
### Via `<script>` tag
110110

111+
To remotely download the full code as an ES module:
112+
111113
```html
112-
<script src="https://unpkg.com/@tubular/time/dist/data/timezone-large-alt.js"></script>
113-
<script src="https://unpkg.com/@tubular/time/dist/web/index.js"></script>
114+
<script type="module">
115+
import('https://unpkg.com/@tubular/time/dist/fesm2015/index.mjs').then(pkg => {
116+
const { ttime, DateTime, Timezone} = pkg;
117+
118+
// ...
119+
});
120+
</script>
114121
```
115122

116-
_(For ES5-compatible code, use `https://unpkg.com/@tubular/time/dist/web5/index.js"`)_
123+
For the old-fashioned UMD approach (which can save you from about 560K of extra data):
117124

118-
The first script element is an example of optionally loading extended timezone definitions. Such a script element, if used, should precede the `index.js` script.
125+
```html
126+
<script src="https://unpkg.com/@tubular/time/dist/data/timezone-large-alt.js"></script>
127+
<script src="https://unpkg.com/@tubular/time/dist/umd/index.js"></script>
128+
```
129+
130+
The script element just above the `index.js` URL is an example of _optionally_ loading extended timezone definitions. Such a script element, if used, should precede the `index.js` script.
119131

120132
The **@tubular/time** package will be available via the global variable `tbTime`. `tbTime.ttime` is the default function, and other functions, classes, and constants will also be available on this variable, such as `tbTime.DateTime`, `tbTime.julianDay`, `tbTime.TIME_MS`, etc.
121133

@@ -603,6 +615,8 @@ Examples of using `set()`:
603615
`ttime('1690-09-15').set('month', 5).toIsoString(10)` → `1690-02-15`<br>
604616
`ttime('1690-09-15').set('month', 13, true).toIsoString(10)` → `1691-01-15`
605617

618+
There is a corresponding `get()` method which returns the numeric value of a field, or `undefined` if the field does not exist.
619+
606620
### Using `startOf()` and `endOf()`
607621

608622
These functions transform a `DateTime` to the beginning or end of a given unit of time.

0 commit comments

Comments
 (0)