Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unixtimestamp32 to standard lib #2579

Merged
merged 6 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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