Skip to content

Commit

Permalink
Add unixtimestamp32 to standard lib (#2579)
Browse files Browse the repository at this point in the history
fix #2543
  • Loading branch information
timotheeguerin authored Oct 18, 2023
1 parent af5ad70 commit 8d24f2f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/compiler",
"comment": "Add new `unixTimestamp32` scalar to standard library",
"type": "none"
}
],
"packageName": "@typespec/compiler"
}
11 changes: 11 additions & 0 deletions docs/standard-library/built-in-data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,17 @@ scalar uint8



### `unixTimestamp32` {#unixTimestamp32}

Represent a 32-bit unix timestamp datetime with 1s of granularity.
It measures time by the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970.

```typespec
scalar unixTimestamp32
```



### `url` {#url}

Represent a URL string as described by https://url.spec.whatwg.org/
Expand Down
8 changes: 8 additions & 0 deletions packages/compiler/lib/lib.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ scalar duration;
*/
scalar boolean;

/**
* Represent a 32-bit unix timestamp datetime with 1s of granularity.
* It measures time by the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970.
*
*/
@encode("unixTimestamp", int32)
scalar unixTimestamp32 extends utcDateTime;

/**
* Represent a model
*/
Expand Down

0 comments on commit 8d24f2f

Please sign in to comment.