Skip to content

Commit

Permalink
Clean up documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Laursen <[email protected]>
  • Loading branch information
jlaur committed Jan 14, 2025
1 parent 9a4476d commit 024b6ed
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions src/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
3 changes: 1 addition & 2 deletions types/time.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion types/time.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 024b6ed

Please sign in to comment.