Skip to content

Commit 227273c

Browse files
committed
add builtin time and duration
1 parent 853617c commit 227273c

17 files changed

+94
-13
lines changed

builtin/c.map

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bool=_Bool
1212
string=char*
1313
byte=uint8_t
1414
bytes=uint8_t*
15+
time=time_t
16+
duration=int64_t
1517
any=void*
1618
array=%T%[%N%]
1719
# map=<c.map: not supported by default>

builtin/cpp.map

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bool=bool
1212
string=std::string
1313
byte=unsigned char
1414
bytes=std::vector<unsigned char>
15+
time=std::time_t
16+
duration=int64_t
1517
any=std::any
1618
map=std::unordered_map<%K%, %V%>
1719
vector=std::vector<%T%>

builtin/csharp.map

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bool=bool
1212
string=string
1313
byte=byte
1414
bytes=byte[]
15+
time=System.DateTime
16+
duration=System.TimeSpan
1517
any=object
1618
map=Dictionary<%K%, %V%>
1719
vector=List<%T%>

builtin/go.map

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bool=bool
1212
string=string
1313
byte=byte
1414
bytes=[]byte
15+
time=time.Time
16+
duration=time.Duration
1517
any=any
1618
map=map[%K%]%V%
1719
vector=[]%T%

builtin/java.map

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bool=boolean
1212
string=String
1313
byte=byte
1414
bytes=byte[]
15+
time=java.time.ZonedDateTime
16+
duration=java.time.Duration
1517
any=Object
1618
map=Map<box(%K%), box(%V%)>
1719
vector=List<box(%T%)>

builtin/js.map

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bool=Boolean
1212
string=String
1313
byte=Number
1414
bytes=Uint8Array
15+
time=Date
16+
duration=BigInt
1517
any=Object
1618
map=Map
1719
vector=Array

builtin/lua.map

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ int=number
55
int8=number
66
int16=number
77
int32=number
8-
int64=number
8+
int64=integer
99
float32=number
1010
float64=number
1111
bool=boolean
1212
string=string
1313
byte=number
1414
bytes=string
15+
time=integer
16+
duration=integer
1517
any=any
1618
map=table
1719
vector=table

builtin/php.map

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bool=bool
1212
string=string
1313
byte=int
1414
bytes=string
15+
time=DateTime
16+
duration=DateInterval
1517
any=mixed
1618
map=array
1719
vector=array

builtin/protobuf.map

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bool=bool
1212
string=string
1313
byte=int32
1414
bytes=bytes
15+
time=int64
16+
duration=int64
1517
any=google.protobuf.Any
1618
map=map<%K%, %V%>
1719
vector=repeated %T.E%

builtin/python.map

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bool=bool
1212
string=str
1313
byte=int
1414
bytes=bytes
15+
time=int
16+
duration=int
1517
any=Any
1618
map=Dict[%K%, %V%]
1719
vector=List[%T%]

builtin/rust.map

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bool=bool
1212
string=String
1313
byte=u8
1414
bytes=Vec<u8>
15+
time=std::time::SystemTime
16+
duration=std::time::Duration
1517
any=Box<dyn Any>
1618
map=HashMap<%K%, %V%>
1719
vector=Vec<%T%>

builtin/ts.map

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bool=boolean
1212
string=string
1313
byte=number
1414
bytes=Uint8Array
15+
time=Date
16+
duration=bigint
1517
any=any
1618
map=Map<%K%, %V%>
1719
vector=Array<%T%>

src/compile/kind.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ func (k Kind) grammarType() string {
7676
// - **byte**: byte
7777
// - **bytes**: byte slice
7878
// - **string**: string
79+
// - **time**: time
80+
// - **duration**: duration
7981
// - **any**: any object
8082
// - **map**: dictionary
8183
// - **vector**: vector of elements
@@ -96,6 +98,8 @@ const (
9698
KindByte // byte
9799
KindBytes // bytes
98100
KindString // string
101+
KindTime // time
102+
KindDuration // duration
99103
KindAny // any
100104
KindMap // map
101105
KindVector // vector
@@ -177,7 +181,7 @@ func (k Kind) Bits() int {
177181

178182
// @api(Object/Common/Type/Kind.IsPrimitive) reports whether the type is a [PrimitiveType](#Object/PrimitiveType).
179183
func (k Kind) IsPrimitive() bool {
180-
return k.IsNumeric() || k.IsString() || k.IsBytes() || k.IsBool() || k.IsAny()
184+
return k.IsNumeric() || k.IsString() || k.IsBytes() || k.IsBool() || k.IsAny() || k.IsTime() || k.IsDuration()
181185
}
182186

183187
// @api(Object/Common/Type/Kind.IsInteger) reports whether the type is an integer.
@@ -216,6 +220,12 @@ func (k Kind) IsBytes() bool { return k == KindBytes }
216220
// @api(Object/Common/Type/Kind.IsBool) reports whether the type is a boolean.
217221
func (k Kind) IsBool() bool { return k == KindBool }
218222

223+
// @api(Object/Common/Type/Kind.IsTime) reports whether the type is a time.
224+
func (k Kind) IsTime() bool { return k == KindTime }
225+
226+
// @api(Object/Common/Type/Kind.IsDuration) reports whether the type is a duration.
227+
func (k Kind) IsDuration() bool { return k == KindDuration }
228+
219229
// @api(Object/Common/Type/Kind.IsAny) reports whether the type is any.
220230
func (k Kind) IsAny() bool { return k == KindAny }
221231

@@ -272,5 +282,7 @@ var primitiveKinds = []Kind{
272282
KindByte,
273283
KindBytes,
274284
KindString,
285+
KindTime,
286+
KindDuration,
275287
KindAny,
276288
}

src/compile/kind_string.go

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

website/docs/api/latest/object.mdx

+27
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,13 @@ If you want to check whether the annotation has a non-empty value, you can use t
225225

226226
</div>
227227

228+
###### .Len {#user-content-Object_Common_Annotation__Len}
229+
<div className="property-container">
230+
231+
`.Len` returns the number of parameters in the annotation.
232+
233+
</div>
234+
228235
###### .NamePos {#user-content-Object_Common_Annotation__NamePos}
229236
<div className="property-container">
230237

@@ -1121,6 +1128,8 @@ false
11211128
- **byte**: byte
11221129
- **bytes**: byte slice
11231130
- **string**: string
1131+
- **time**: time
1132+
- **duration**: duration
11241133
- **any**: any object
11251134
- **map**: dictionary
11261135
- **vector**: vector of elements
@@ -1178,6 +1187,13 @@ false
11781187
11791188
</div>
11801189
1190+
###### .IsDuration {#user-content-Object_Common_Type_Kind__IsDuration}
1191+
<div className="property-container">
1192+
1193+
`.IsDuration` reports whether the type is a duration.
1194+
1195+
</div>
1196+
11811197
###### .IsEnum {#user-content-Object_Common_Type_Kind__IsEnum}
11821198
<div className="property-container">
11831199
@@ -1241,6 +1257,13 @@ false
12411257
12421258
</div>
12431259
1260+
###### .IsTime {#user-content-Object_Common_Type_Kind__IsTime}
1261+
<div className="property-container">
1262+
1263+
`.IsTime` reports whether the type is a time.
1264+
1265+
</div>
1266+
12441267
###### .IsVector {#user-content-Object_Common_Type_Kind__IsVector}
12451268
<div className="property-container">
12461269
@@ -2108,6 +2131,10 @@ Example:
21082131
21092132
</div>
21102133
2134+
## Packages {#user-content-Object_Packages}
2135+
2136+
`Packages` represents a list of Next packages.
2137+
21112138
## PrimitiveType {#user-content-Object_PrimitiveType}
21122139
21132140
`PrimitiveType` represents a primitive type.

website/docs/api/preview/object.mdx

+16
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,8 @@ false
11281128
- **byte**: byte
11291129
- **bytes**: byte slice
11301130
- **string**: string
1131+
- **time**: time
1132+
- **duration**: duration
11311133
- **any**: any object
11321134
- **map**: dictionary
11331135
- **vector**: vector of elements
@@ -1185,6 +1187,13 @@ false
11851187
11861188
</div>
11871189
1190+
###### .IsDuration {#user-content-Object_Common_Type_Kind__IsDuration}
1191+
<div className="property-container">
1192+
1193+
`.IsDuration` reports whether the type is a duration.
1194+
1195+
</div>
1196+
11881197
###### .IsEnum {#user-content-Object_Common_Type_Kind__IsEnum}
11891198
<div className="property-container">
11901199
@@ -1248,6 +1257,13 @@ false
12481257
12491258
</div>
12501259
1260+
###### .IsTime {#user-content-Object_Common_Type_Kind__IsTime}
1261+
<div className="property-container">
1262+
1263+
`.IsTime` reports whether the type is a time.
1264+
1265+
</div>
1266+
12511267
###### .IsVector {#user-content-Object_Common_Type_Kind__IsVector}
12521268
<div className="property-container">
12531269

website/docusaurus.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const PROJECT_NAME = "next";
1212
const REPO = `https://github.com/${ORGANIZATION_NAME}/${PROJECT_NAME}`;
1313

1414
const customFields = {
15-
version: "0.2.7",
15+
version: "0.2.8",
1616
repo: REPO,
1717
};
1818

0 commit comments

Comments
 (0)