Skip to content

Commit 9a71cbd

Browse files
committed
Code cleanup. JSDoc improvements.
1 parent bb5b234 commit 9a71cbd

14 files changed

+1447
-72
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ import minitz from "minitz";
7979
JavaScript
8080

8181
```javascript
82-
import minitz from "https://deno.land/x/[email protected].1/src/minitz.js";
82+
import minitz from "https://deno.land/x/[email protected].3/src/minitz.js";
8383

8484
// ...
8585
```
8686

8787
TypeScript
8888

8989
```typescript
90-
import { minitz } from "https://deno.land/x/[email protected].1/src/minitz.js";
90+
import { minitz } from "https://deno.land/x/[email protected].3/src/minitz.js";
9191

9292
// ...
9393
```

dist/minitz.cjs

+20-15
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
* @property {string} timezone - Time zone in IANA database format 'Europe/Stockholm'
4444
*/
4545

46-
/*
46+
/**
4747
* Converts a date/time from a specific timezone to a normal date object using the system local time
4848
*
4949
* Shortcut for minitz.fromTZ(minitz.tp(...));
5050
*
51-
* @public
51+
* @constructor
5252
*
5353
* @param {Number} year - 1970--
5454
* @param {Number} month - 1-12
@@ -59,39 +59,42 @@
5959
* @param {string} timezone - Time zone in IANA database format 'Europe/Stockholm'
6060
* @param {boolean} [throwOnInvalidTime] - Default is to return the adjusted time if the call happens during a Daylight-Saving-Time switch.
6161
* E.g. Value "01:01:01" is returned if input time is 00:01:01 while one hour got actually
62-
* skipped, going from 23:59:59 to 01:00:00. Setting this flag makes the library throw instead.
62+
* skipped, going from 23:59:59 to 01:00:00. Setting this flag makes the library throw an exception instead.
6363
* @returns {date} - Normal date object with correct UTC and system local time
6464
*
65-
*/
65+
*/
6666
function minitz(year, month, day, hour, minute, second, timezone, throwOnInvalidTime) {
6767
return minitz.fromTZ(minitz.tp(year, month, day, hour, minute, second, timezone), throwOnInvalidTime);
6868
}
6969

7070
/**
7171
* Converts a date/time from a specific timezone to a normal date object using the system local time
72-
*
72+
*
7373
* @public
74-
*
74+
* @static
75+
*
7576
* @param {string} localTimeString - ISO8601 formatted local time string, non UTC
7677
* @param {string} timezone - Time zone in IANA database format 'Europe/Stockholm'
7778
* @param {boolean} [throwOnInvalidTime] - Default is to return the adjusted time if the call happens during a Daylight-Saving-Time switch.
7879
* E.g. Value "01:01:01" is returned if input time is 00:01:01 while one hour got actually
79-
* skipped, going from 23:59:59 to 01:00:00. Setting this flag makes the library throw instead.
80-
* @returns {date} - Normal date object
80+
* skipped, going from 23:59:59 to 01:00:00. Setting this flag makes the library throw an exception instead.
81+
* @return {date} - Normal date object
82+
*
8183
*/
82-
minitz.fromTZISO = function(localTimeString, timezone, throwOnInvalidTime) {
84+
minitz.fromTZISO = (localTimeString, timezone, throwOnInvalidTime) => {
8385
return minitz.fromTZ(parseISOLocal(localTimeString, timezone), throwOnInvalidTime);
8486
};
8587

8688
/**
8789
* Converts a date/time from a specific timezone to a normal date object using the system local time
8890
*
8991
* @public
92+
* @static
9093
*
9194
* @param {TimePoint} date - Object with specified timezone
9295
* @param {boolean} [throwOnInvalidTime] - Default is to return the adjusted time if the call happens during a Daylight-Saving-Time switch.
9396
* E.g. Value "01:01:01" is returned if input time is 00:01:01 while one hour got actually
94-
* skipped, going from 23:59:59 to 01:00:00. Setting this flag makes the library throw instead.
97+
* skipped, going from 23:59:59 to 01:00:00. Setting this flag makes the library throw an exception instead.
9598
* @returns {date} - Normal date object
9699
*/
97100
minitz.fromTZ = function(timePoint, throwOnInvalidTime) {
@@ -150,6 +153,7 @@
150153
* time zone, use vanilla JS. See the example below.
151154
*
152155
* @public
156+
* @static
153157
*
154158
* @param {date} date - Input date
155159
* @param {string} [tzString] - Timezone string in Europe/Stockholm format
@@ -192,10 +196,11 @@
192196
};
193197
};
194198

195-
/*
199+
/**
196200
* Convenience function which returns a TimePoint object for later use in fromTZ
197201
*
198202
* @public
203+
* @static
199204
*
200205
* @param {Number} year - 1970--
201206
* @param {Number} month - 1-12
@@ -220,11 +225,11 @@
220225
*
221226
* @returns {number} - Offset in ms between UTC and timeZone
222227
*/
223-
const getTimezoneOffset = (timeZone, date = new Date()) => {
228+
function getTimezoneOffset(timeZone, date = new Date()) {
224229
const tz = date.toLocaleString("en", {timeZone, timeStyle: "long"}).split(" ").slice(-1)[0];
225230
const dateString = date.toString();
226231
return Date.parse(`${dateString} UTC`) - Date.parse(`${dateString} ${tz}`);
227-
};
232+
}
228233

229234

230235
/**
@@ -237,7 +242,7 @@
237242
* with all components, e.g. 2015-11-24T19:40:00
238243
* @returns {TimePoint} - TimePoint instance from parsing the string
239244
*/
240-
const parseISOLocal = function (dateTimeString, timezone) {
245+
function parseISOLocal(dateTimeString, timezone) {
241246
const dateTimeStringSplit = dateTimeString.split(/\D/);
242247

243248
// Check for completeness
@@ -277,7 +282,7 @@
277282
return minitz.tp(year, month, day, hour, minute, second, timezone);
278283
}
279284
}
280-
};
285+
}
281286

282287
minitz.minitz = minitz;
283288

dist/minitz.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/minitz.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)