9
9
"path"
10
10
"strconv"
11
11
"strings"
12
+ "time"
12
13
13
14
"github.com/mitchellh/mapstructure"
14
15
)
@@ -29,11 +30,15 @@ type Repository struct {
29
30
Has_wiki bool
30
31
Mainbranch RepositoryBranch
31
32
Type string
32
- CreatedOn string `mapstructure:"created_on"`
33
- UpdatedOn string `mapstructure:"updated_on"`
34
- Owner map [string ]interface {}
35
- Links map [string ]interface {}
36
- Parent * Repository
33
+ // Deprecated: CreatedOn is deprecated use CreatedOnTime
34
+ CreatedOn string `mapstructure:"created_on"`
35
+ // Deprecated: UpdatedOn is deprecated use UpdatedOnTime
36
+ UpdatedOn string `mapstructure:"updated_on"`
37
+ Owner map [string ]interface {}
38
+ Links map [string ]interface {}
39
+ Parent * Repository
40
+ CreatedOnTime * time.Time `mapstructure:"created_on"`
41
+ UpdatedOnTime * time.Time `mapstructure:"updated_on"`
37
42
}
38
43
39
44
type RepositoryFile struct {
@@ -249,6 +254,8 @@ type UserPermissions struct {
249
254
UserPermissions []UserPermission
250
255
}
251
256
257
+ var stringToTimeHookFunc = mapstructure .StringToTimeHookFunc ("2006-01-02T15:04:05.000000+00:00" )
258
+
252
259
func (r * Repository ) Create (ro * RepositoryOptions ) (* Repository , error ) {
253
260
data , err := r .buildRepositoryBody (ro )
254
261
if err != nil {
@@ -1190,7 +1197,15 @@ func decodeRepository(repoResponse interface{}) (*Repository, error) {
1190
1197
}
1191
1198
1192
1199
var repository = new (Repository )
1193
- err := mapstructure .Decode (repoMap , repository )
1200
+ decoder , err := mapstructure .NewDecoder (& mapstructure.DecoderConfig {
1201
+ Metadata : nil ,
1202
+ Result : repository ,
1203
+ DecodeHook : stringToTimeHookFunc ,
1204
+ })
1205
+ if err != nil {
1206
+ return nil , err
1207
+ }
1208
+ err = decoder .Decode (repoMap )
1194
1209
if err != nil {
1195
1210
return nil , err
1196
1211
}
0 commit comments