From 024b6ed90b022956c1c7577efcc803fe6ad6245f Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Tue, 14 Jan 2025 23:28:46 +0100 Subject: [PATCH] Clean up documentation Signed-off-by: Jacob Laursen --- README.md | 21 ++++++++++----------- src/time.js | 3 +-- types/time.d.ts | 3 +-- types/time.d.ts.map | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f4283fc7..5b341ad5 100644 --- a/README.md +++ b/README.md @@ -1093,17 +1093,16 @@ console.log(timestamp.getMillisFromNow()); The following rules are used during the conversion: -| Argument Type | Rule | Examples | -|------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|----------------------------------------------| -| `null` or `undefined` | `time.Instant.now()` | `time.toInstant();` | -| `time.Instant` | passed through unmodified | | -| `java.time.Instant` | converted to the `time.Instant` equivalent | | -| `java.time.ZonedDateTime` | converted to the `time.Instant` equivalent | | -| JavaScript native `Date` | converted to the `time.Instant` equivalent | | -| `items.Item` or `org.openhab.core.types.Item` | if the state is supported (see the `Type` rules in this table, e.g. `DecimalType`), the state is converted | `time.toInstant(items.getItem('MyItem'));` | -| `String`, `java.lang.String`, `StringType` | parsed ISO Instant | `time.toInstant('2019-10-12T07:20:50.52Z');` | -| [ISO8601 Date/Time](https://en.wikipedia.org/wiki/ISO_8601) String | | | -| RFC String (output from a Java `Instant.toString()`) | | | +| Argument Type | Rule | Examples | +|-----------------------------------------------|-----------------------------------------------------------------------------------------|----------------------------------------------| +| `null` or `undefined` | `time.Instant.now()` | `time.toInstant();` | +| `time.Instant` | passed through unmodified | | +| `java.time.Instant` | converted to the `time.Instant` equivalent | | +| `java.time.ZonedDateTime` | converted to the `time.Instant` equivalent | | +| JavaScript native `Date` | converted to the `time.Instant` equivalent | | +| `items.Item` or `org.openhab.core.types.Item` | if the state is supported (see the `Type` rules in this table), the state is converted | `time.toInstant(items.getItem('MyItem'));` | +| `String`, `java.lang.String`, `StringType` | parsed | `time.toInstant('2019-10-12T07:20:50.52Z');` | +| `DateTimeType` | converted to the `time.Instant` equivalent | | When a type or string that cannot be handled is encountered, an error is thrown. diff --git a/src/time.js b/src/time.js index 242b479e..fe6a70cd 100644 --- a/src/time.js +++ b/src/time.js @@ -361,8 +361,7 @@ time.ZonedDateTime.prototype.toToday = function () { * - Java Instant, DateTimeType: converted to time.Instant equivalent * - JavaScript native {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date Date}: converted to a `time.Instant` * - Item: converts the state of the Item based on the *Type rules described here - * - String, Java String, StringType: parsed ISO Instant - * - RFC (output from a Java Instant.toString()): parsed to time.Instant + * - String, Java String, StringType: parsed * @memberof time * @param {*} [when] any of the types discussed above * @returns {time.Instant} diff --git a/types/time.d.ts b/types/time.d.ts index 4a85be6b..02541347 100644 --- a/types/time.d.ts +++ b/types/time.d.ts @@ -125,8 +125,7 @@ declare function toZDT(when?: any): time.ZonedDateTime; * - Java Instant, DateTimeType: converted to time.Instant equivalent * - JavaScript native {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date Date}: converted to a `time.Instant` * - Item: converts the state of the Item based on the *Type rules described here - * - String, Java String, StringType: parsed ISO Instant - * - RFC (output from a Java Instant.toString()): parsed to time.Instant + * - String, Java String, StringType: parsed * @memberof time * @param {*} [when] any of the types discussed above * @returns {time.Instant} diff --git a/types/time.d.ts.map b/types/time.d.ts.map index 7b5540ad..f2b90d33 100644 --- a/types/time.d.ts.map +++ b/types/time.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.js"],"names":[],"mappings":";;;;;;;;;;;;;IAAA;;;;;OAKG;IAEH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8MH;;;;;;GAMG;AACH,+DAFa,KAAK,OAAO,CAIxB;AAED;;;;;;GAMG;AACH,yDAFa,KAAK,aAAa,CAO9B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,oCAHa,KAAK,aAAa,CA+E9B;AAcD;;;;;;;;;;;;;;;;GAgBG;AACH,wCAHa,KAAK,OAAO,CA6DxB;AA3SD;;;;;;;GAOG;AACH,mCAJW,MAAM,GACJ,KAAK,aAAa,CA0C9B;AAnFD;;;;;;;;;;;;GAYG;AACH,6CAHa,KAAK,aAAa,GAAC,IAAI,CAwBnC"} \ No newline at end of file +{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.js"],"names":[],"mappings":";;;;;;;;;;;;;IAAA;;;;;OAKG;IAEH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8MH;;;;;;GAMG;AACH,+DAFa,KAAK,OAAO,CAIxB;AAED;;;;;;GAMG;AACH,yDAFa,KAAK,aAAa,CAO9B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,oCAHa,KAAK,aAAa,CA+E9B;AAcD;;;;;;;;;;;;;;;GAeG;AACH,wCAHa,KAAK,OAAO,CA6DxB;AA1SD;;;;;;;GAOG;AACH,mCAJW,MAAM,GACJ,KAAK,aAAa,CA0C9B;AAnFD;;;;;;;;;;;;GAYG;AACH,6CAHa,KAAK,aAAa,GAAC,IAAI,CAwBnC"} \ No newline at end of file