Test case
1 generated file · +1 −1test/inputs/graphql/github1.graphql
Mgraphql-swiftdefault / quicktype.swift+1 −1
| @@ -195,7 +195,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 195 | 195 | let decoder = JSONDecoder() |
| 196 | 196 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 197 | 197 | let container = try decoder.singleValueContainer() |
| 198 | - let dateStr = try container.decode(String.self) | |
| 198 | + let dateStr = try container.decode(String.self).uppercased() | |
| 199 | 199 | |
| 200 | 200 | let formatter = DateFormatter() |
| 201 | 201 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/graphql/github2.graphql
Mgraphql-swiftdefault / quicktype.swift+1 −1
| @@ -287,7 +287,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 287 | 287 | let decoder = JSONDecoder() |
| 288 | 288 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 289 | 289 | let container = try decoder.singleValueContainer() |
| 290 | - let dateStr = try container.decode(String.self) | |
| 290 | + let dateStr = try container.decode(String.self).uppercased() | |
| 291 | 291 | |
| 292 | 292 | let formatter = DateFormatter() |
| 293 | 293 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/graphql/github3.graphql
Mgraphql-swiftdefault / quicktype.swift+1 −1
| @@ -333,7 +333,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 333 | 333 | let decoder = JSONDecoder() |
| 334 | 334 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 335 | 335 | let container = try decoder.singleValueContainer() |
| 336 | - let dateStr = try container.decode(String.self) | |
| 336 | + let dateStr = try container.decode(String.self).uppercased() | |
| 337 | 337 | |
| 338 | 338 | let formatter = DateFormatter() |
| 339 | 339 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/graphql/github4.graphql
Mgraphql-swiftdefault / quicktype.swift+1 −1
| @@ -337,7 +337,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 337 | 337 | let decoder = JSONDecoder() |
| 338 | 338 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 339 | 339 | let container = try decoder.singleValueContainer() |
| 340 | - let dateStr = try container.decode(String.self) | |
| 340 | + let dateStr = try container.decode(String.self).uppercased() | |
| 341 | 341 | |
| 342 | 342 | let formatter = DateFormatter() |
| 343 | 343 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/graphql/github5.graphql
Mgraphql-swiftdefault / quicktype.swift+1 −1
| @@ -195,7 +195,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 195 | 195 | let decoder = JSONDecoder() |
| 196 | 196 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 197 | 197 | let container = try decoder.singleValueContainer() |
| 198 | - let dateStr = try container.decode(String.self) | |
| 198 | + let dateStr = try container.decode(String.self).uppercased() | |
| 199 | 199 | |
| 200 | 200 | let formatter = DateFormatter() |
| 201 | 201 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/graphql/github6.graphql
Mgraphql-swiftdefault / quicktype.swift+1 −1
| @@ -195,7 +195,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 195 | 195 | let decoder = JSONDecoder() |
| 196 | 196 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 197 | 197 | let container = try decoder.singleValueContainer() |
| 198 | - let dateStr = try container.decode(String.self) | |
| 198 | + let dateStr = try container.decode(String.self).uppercased() | |
| 199 | 199 | |
| 200 | 200 | let formatter = DateFormatter() |
| 201 | 201 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/graphql/github7.graphql
Mgraphql-swiftdefault / quicktype.swift+1 −1
| @@ -391,7 +391,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 391 | 391 | let decoder = JSONDecoder() |
| 392 | 392 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 393 | 393 | let container = try decoder.singleValueContainer() |
| 394 | - let dateStr = try container.decode(String.self) | |
| 394 | + let dateStr = try container.decode(String.self).uppercased() | |
| 395 | 395 | |
| 396 | 396 | let formatter = DateFormatter() |
| 397 | 397 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/graphql/github8.graphql
Mgraphql-swiftdefault / quicktype.swift+1 −1
| @@ -256,7 +256,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 256 | 256 | let decoder = JSONDecoder() |
| 257 | 257 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 258 | 258 | let container = try decoder.singleValueContainer() |
| 259 | - let dateStr = try container.decode(String.self) | |
| 259 | + let dateStr = try container.decode(String.self).uppercased() | |
| 260 | 260 | |
| 261 | 261 | let formatter = DateFormatter() |
| 262 | 262 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/graphql/github9.graphql
Mgraphql-swiftdefault / quicktype.swift+1 −1
| @@ -300,7 +300,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 300 | 300 | let decoder = JSONDecoder() |
| 301 | 301 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 302 | 302 | let container = try decoder.singleValueContainer() |
| 303 | - let dateStr = try container.decode(String.self) | |
| 303 | + let dateStr = try container.decode(String.self).uppercased() | |
| 304 | 304 | |
| 305 | 305 | let formatter = DateFormatter() |
| 306 | 306 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/00c36.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -240,7 +240,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 240 | 240 | let decoder = JSONDecoder() |
| 241 | 241 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 242 | 242 | let container = try decoder.singleValueContainer() |
| 243 | - let dateStr = try container.decode(String.self) | |
| 243 | + let dateStr = try container.decode(String.self).uppercased() | |
| 244 | 244 | |
| 245 | 245 | let formatter = DateFormatter() |
| 246 | 246 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/00ec5.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -623,7 +623,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 623 | 623 | let decoder = JSONDecoder() |
| 624 | 624 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 625 | 625 | let container = try decoder.singleValueContainer() |
| 626 | - let dateStr = try container.decode(String.self) | |
| 626 | + let dateStr = try container.decode(String.self).uppercased() | |
| 627 | 627 | |
| 628 | 628 | let formatter = DateFormatter() |
| 629 | 629 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/010b1.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -106,7 +106,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 106 | 106 | let decoder = JSONDecoder() |
| 107 | 107 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 108 | 108 | let container = try decoder.singleValueContainer() |
| 109 | - let dateStr = try container.decode(String.self) | |
| 109 | + let dateStr = try container.decode(String.self).uppercased() | |
| 110 | 110 | |
| 111 | 111 | let formatter = DateFormatter() |
| 112 | 112 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/016af.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/033b1.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/050b0.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -337,7 +337,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 337 | 337 | let decoder = JSONDecoder() |
| 338 | 338 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 339 | 339 | let container = try decoder.singleValueContainer() |
| 340 | - let dateStr = try container.decode(String.self) | |
| 340 | + let dateStr = try container.decode(String.self).uppercased() | |
| 341 | 341 | |
| 342 | 342 | let formatter = DateFormatter() |
| 343 | 343 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/06bee.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -282,7 +282,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 282 | 282 | let decoder = JSONDecoder() |
| 283 | 283 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 284 | 284 | let container = try decoder.singleValueContainer() |
| 285 | - let dateStr = try container.decode(String.self) | |
| 285 | + let dateStr = try container.decode(String.self).uppercased() | |
| 286 | 286 | |
| 287 | 287 | let formatter = DateFormatter() |
| 288 | 288 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/07540.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -98,7 +98,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 98 | 98 | let decoder = JSONDecoder() |
| 99 | 99 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 100 | 100 | let container = try decoder.singleValueContainer() |
| 101 | - let dateStr = try container.decode(String.self) | |
| 101 | + let dateStr = try container.decode(String.self).uppercased() | |
| 102 | 102 | |
| 103 | 103 | let formatter = DateFormatter() |
| 104 | 104 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/0779f.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -271,7 +271,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 271 | 271 | let decoder = JSONDecoder() |
| 272 | 272 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 273 | 273 | let container = try decoder.singleValueContainer() |
| 274 | - let dateStr = try container.decode(String.self) | |
| 274 | + let dateStr = try container.decode(String.self).uppercased() | |
| 275 | 275 | |
| 276 | 276 | let formatter = DateFormatter() |
| 277 | 277 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/07c75.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -258,7 +258,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 258 | 258 | let decoder = JSONDecoder() |
| 259 | 259 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 260 | 260 | let container = try decoder.singleValueContainer() |
| 261 | - let dateStr = try container.decode(String.self) | |
| 261 | + let dateStr = try container.decode(String.self).uppercased() | |
| 262 | 262 | |
| 263 | 263 | let formatter = DateFormatter() |
| 264 | 264 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/09f54.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -163,7 +163,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 163 | 163 | let decoder = JSONDecoder() |
| 164 | 164 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 165 | 165 | let container = try decoder.singleValueContainer() |
| 166 | - let dateStr = try container.decode(String.self) | |
| 166 | + let dateStr = try container.decode(String.self).uppercased() | |
| 167 | 167 | |
| 168 | 168 | let formatter = DateFormatter() |
| 169 | 169 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +15 −5test/inputs/json/misc/0a358.json
Mcplusplusdefault / quicktype.hpp+2 −2
| @@ -149,12 +149,12 @@ namespace quicktype { | ||
| 149 | 149 | inline void from_json(const json & j, Result& x) { |
| 150 | 150 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 151 | 151 | x.set_code(j.at("code").get<std::string>()); |
| 152 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 152 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 153 | 153 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 154 | 154 | if (j.find("id") != j.end() && !j.at("id").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 155 | 155 | x.set_id(j.at("id").get<int64_t>()); |
| 156 | 156 | x.set_name(j.at("name").get<std::string>()); |
| 157 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 157 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 158 | 158 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 159 | 159 | x.set_uri(j.at("uri").get<std::string>()); |
| 160 | 160 | } |
Mobjective-cdefault / QTTopLevel.m+4 −2
| @@ -228,12 +228,14 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 228 | 228 | { |
| 229 | 229 | if (self = [super init]) { |
| 230 | 230 | if (![dict[@"code"] isKindOfClass:NSString.class]) return nil; |
| 231 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 231 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 232 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 232 | 233 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 233 | 234 | if (![dict[@"id"] isKindOfClass:NSNumber.class]) return nil; |
| 234 | 235 | if ([dict[@"id"] doubleValue] != [dict[@"id"] longLongValue]) return nil; |
| 235 | 236 | if (![dict[@"name"] isKindOfClass:NSString.class]) return nil; |
| 236 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 237 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 238 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 237 | 239 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 238 | 240 | if (![dict[@"uri"] isKindOfClass:NSString.class]) return nil; |
| 239 | 241 | [self setValuesForKeysWithDictionary:dict]; |
Mphpdefault / TopLevel.php+8 −0
| @@ -583,6 +583,10 @@ class Result { | ||
| 583 | 583 | */ |
| 584 | 584 | public static function fromCreatedAt(string $value): DateTime { |
| 585 | 585 | $tmp = new DateTime($value); |
| 586 | + $errors = DateTime::getLastErrors(); | |
| 587 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 588 | + throw new Exception('Invalid date-time'); | |
| 589 | + } | |
| 586 | 590 | if (!is_a($tmp, 'DateTime')) { |
| 587 | 591 | throw new Exception('Attribute Error:Result::'); |
| 588 | 592 | } |
| @@ -731,6 +735,10 @@ class Result { | ||
| 731 | 735 | */ |
| 732 | 736 | public static function fromUpdatedAt(string $value): DateTime { |
| 733 | 737 | $tmp = new DateTime($value); |
| 738 | + $errors = DateTime::getLastErrors(); | |
| 739 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 740 | + throw new Exception('Invalid date-time'); | |
| 741 | + } | |
| 734 | 742 | if (!is_a($tmp, 'DateTime')) { |
| 735 | 743 | throw new Exception('Attribute Error:Result::'); |
| 736 | 744 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -186,7 +186,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 186 | 186 | let decoder = JSONDecoder() |
| 187 | 187 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 188 | 188 | let container = try decoder.singleValueContainer() |
| 189 | - let dateStr = try container.decode(String.self) | |
| 189 | + let dateStr = try container.decode(String.self).uppercased() | |
| 190 | 190 | |
| 191 | 191 | let formatter = DateFormatter() |
| 192 | 192 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +57 −17test/inputs/json/misc/0a91a.json
Mcplusplusdefault / quicktype.hpp+8 −8
| @@ -1243,7 +1243,7 @@ namespace quicktype { | ||
| 1243 | 1243 | x.set_compare_url(j.at("compare_url").get<std::string>()); |
| 1244 | 1244 | x.set_contents_url(j.at("contents_url").get<std::string>()); |
| 1245 | 1245 | x.set_contributors_url(j.at("contributors_url").get<std::string>()); |
| 1246 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1246 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1247 | 1247 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 1248 | 1248 | x.set_default_branch(j.at("default_branch").get<std::string>()); |
| 1249 | 1249 | x.set_deployments_url(j.at("deployments_url").get<std::string>()); |
| @@ -1289,7 +1289,7 @@ namespace quicktype { | ||
| 1289 | 1289 | x.set_open_issues_count(j.at("open_issues_count").get<int64_t>()); |
| 1290 | 1290 | x.set_owner(j.at("owner").get<MergedBy>()); |
| 1291 | 1291 | x.set_pulls_url(j.at("pulls_url").get<std::string>()); |
| 1292 | - if (j.find("pushed_at") != j.end() && !std::regex_match(j.at("pushed_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1292 | + if (j.find("pushed_at") != j.end() && !std::regex_match(j.at("pushed_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1293 | 1293 | x.set_pushed_at(j.at("pushed_at").get<std::string>()); |
| 1294 | 1294 | x.set_releases_url(j.at("releases_url").get<std::string>()); |
| 1295 | 1295 | x.set_repo_private(j.at("private").get<bool>()); |
| @@ -1306,7 +1306,7 @@ namespace quicktype { | ||
| 1306 | 1306 | x.set_tags_url(j.at("tags_url").get<std::string>()); |
| 1307 | 1307 | x.set_teams_url(j.at("teams_url").get<std::string>()); |
| 1308 | 1308 | x.set_trees_url(j.at("trees_url").get<std::string>()); |
| 1309 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1309 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1310 | 1310 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 1311 | 1311 | x.set_url(j.at("url").get<std::string>()); |
| 1312 | 1312 | if (j.find("watchers") != j.end() && !j.at("watchers").is_number_integer()) throw std::runtime_error("Expected integer"); |
| @@ -1450,7 +1450,7 @@ namespace quicktype { | ||
| 1450 | 1450 | x.set_body(j.at("body").get<std::string>()); |
| 1451 | 1451 | if (j.find("changed_files") != j.end() && !j.at("changed_files").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 1452 | 1452 | x.set_changed_files(j.at("changed_files").get<int64_t>()); |
| 1453 | - if (j.find("closed_at") != j.end() && !std::regex_match(j.at("closed_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1453 | + if (j.find("closed_at") != j.end() && !std::regex_match(j.at("closed_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1454 | 1454 | x.set_closed_at(j.at("closed_at").get<std::string>()); |
| 1455 | 1455 | if (j.find("comments") != j.end() && !j.at("comments").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 1456 | 1456 | x.set_comments(j.at("comments").get<int64_t>()); |
| @@ -1458,7 +1458,7 @@ namespace quicktype { | ||
| 1458 | 1458 | if (j.find("commits") != j.end() && !j.at("commits").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 1459 | 1459 | x.set_commits(j.at("commits").get<int64_t>()); |
| 1460 | 1460 | x.set_commits_url(j.at("commits_url").get<std::string>()); |
| 1461 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1461 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1462 | 1462 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 1463 | 1463 | if (j.find("deletions") != j.end() && !j.at("deletions").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 1464 | 1464 | x.set_deletions(j.at("deletions").get<int64_t>()); |
| @@ -1475,7 +1475,7 @@ namespace quicktype { | ||
| 1475 | 1475 | x.set_mergeable(get_untyped(j, "mergeable")); |
| 1476 | 1476 | x.set_mergeable_state(j.at("mergeable_state").get<std::string>()); |
| 1477 | 1477 | x.set_merged(j.at("merged").get<bool>()); |
| 1478 | - if (j.find("merged_at") != j.end() && !std::regex_match(j.at("merged_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1478 | + if (j.find("merged_at") != j.end() && !std::regex_match(j.at("merged_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1479 | 1479 | x.set_merged_at(j.at("merged_at").get<std::string>()); |
| 1480 | 1480 | x.set_merged_by(j.at("merged_by").get<MergedBy>()); |
| 1481 | 1481 | x.set_milestone(get_untyped(j, "milestone")); |
| @@ -1491,7 +1491,7 @@ namespace quicktype { | ||
| 1491 | 1491 | x.set_state(j.at("state").get<std::string>()); |
| 1492 | 1492 | x.set_statuses_url(j.at("statuses_url").get<std::string>()); |
| 1493 | 1493 | x.set_title(j.at("title").get<std::string>()); |
| 1494 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1494 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1495 | 1495 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 1496 | 1496 | x.set_url(j.at("url").get<std::string>()); |
| 1497 | 1497 | x.set_user(j.at("user").get<MergedBy>()); |
| @@ -1613,7 +1613,7 @@ namespace quicktype { | ||
| 1613 | 1613 | inline void from_json(const json & j, TopLevelElement& x) { |
| 1614 | 1614 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 1615 | 1615 | x.set_actor(j.at("actor").get<Actor>()); |
| 1616 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1616 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1617 | 1617 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 1618 | 1618 | x.set_id(j.at("id").get<std::string>()); |
| 1619 | 1619 | if (j.find("org") != j.end() && j.at("org").is_null()) throw std::runtime_error("Unexpected null"); |
Mobjective-cdefault / QTTopLevel.m+16 −8
| @@ -175,7 +175,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 175 | 175 | { |
| 176 | 176 | if (self = [super init]) { |
| 177 | 177 | if (![dict[@"actor"] isKindOfClass:NSDictionary.class]) return nil; |
| 178 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 178 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 179 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 179 | 180 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 180 | 181 | if (![dict[@"id"] isKindOfClass:NSString.class]) return nil; |
| 181 | 182 | if (![dict[@"public"] isKindOfClass:NSNumber.class]) return nil; |
| @@ -539,7 +540,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 539 | 540 | if (![dict[@"body"] isKindOfClass:NSString.class]) return nil; |
| 540 | 541 | if (![dict[@"changed_files"] isKindOfClass:NSNumber.class]) return nil; |
| 541 | 542 | if ([dict[@"changed_files"] doubleValue] != [dict[@"changed_files"] longLongValue]) return nil; |
| 542 | - if (dict[@"closed_at"] && [dict[@"closed_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 543 | + if (dict[@"closed_at"] && [dict[@"closed_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 544 | + if (dict[@"closed_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"closed_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"closed_at"] substringToIndex:10]]) return nil; | |
| 543 | 545 | if (![dict[@"closed_at"] isKindOfClass:NSString.class]) return nil; |
| 544 | 546 | if (![dict[@"comments"] isKindOfClass:NSNumber.class]) return nil; |
| 545 | 547 | if ([dict[@"comments"] doubleValue] != [dict[@"comments"] longLongValue]) return nil; |
| @@ -547,7 +549,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 547 | 549 | if (![dict[@"commits"] isKindOfClass:NSNumber.class]) return nil; |
| 548 | 550 | if ([dict[@"commits"] doubleValue] != [dict[@"commits"] longLongValue]) return nil; |
| 549 | 551 | if (![dict[@"commits_url"] isKindOfClass:NSString.class]) return nil; |
| 550 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 552 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 553 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 551 | 554 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 552 | 555 | if (![dict[@"deletions"] isKindOfClass:NSNumber.class]) return nil; |
| 553 | 556 | if ([dict[@"deletions"] doubleValue] != [dict[@"deletions"] longLongValue]) return nil; |
| @@ -564,7 +567,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 564 | 567 | if (![dict[@"merge_commit_sha"] isKindOfClass:NSString.class]) return nil; |
| 565 | 568 | if (!dict[@"mergeable"]) return nil; |
| 566 | 569 | if (![dict[@"mergeable_state"] isKindOfClass:NSString.class]) return nil; |
| 567 | - if (dict[@"merged_at"] && [dict[@"merged_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 570 | + if (dict[@"merged_at"] && [dict[@"merged_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 571 | + if (dict[@"merged_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"merged_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"merged_at"] substringToIndex:10]]) return nil; | |
| 568 | 572 | if (![dict[@"merged_at"] isKindOfClass:NSString.class]) return nil; |
| 569 | 573 | if (![dict[@"merged_by"] isKindOfClass:NSDictionary.class]) return nil; |
| 570 | 574 | if (!dict[@"milestone"]) return nil; |
| @@ -580,7 +584,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 580 | 584 | if (![dict[@"state"] isKindOfClass:NSString.class]) return nil; |
| 581 | 585 | if (![dict[@"statuses_url"] isKindOfClass:NSString.class]) return nil; |
| 582 | 586 | if (![dict[@"title"] isKindOfClass:NSString.class]) return nil; |
| 583 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 587 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 588 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 584 | 589 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 585 | 590 | if (![dict[@"url"] isKindOfClass:NSString.class]) return nil; |
| 586 | 591 | if (![dict[@"user"] isKindOfClass:NSDictionary.class]) return nil; |
| @@ -794,7 +799,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 794 | 799 | if (![dict[@"compare_url"] isKindOfClass:NSString.class]) return nil; |
| 795 | 800 | if (![dict[@"contents_url"] isKindOfClass:NSString.class]) return nil; |
| 796 | 801 | if (![dict[@"contributors_url"] isKindOfClass:NSString.class]) return nil; |
| 797 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 802 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 803 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 798 | 804 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 799 | 805 | if (![dict[@"default_branch"] isKindOfClass:NSString.class]) return nil; |
| 800 | 806 | if (![dict[@"deployments_url"] isKindOfClass:NSString.class]) return nil; |
| @@ -840,7 +846,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 840 | 846 | if ([dict[@"open_issues_count"] doubleValue] != [dict[@"open_issues_count"] longLongValue]) return nil; |
| 841 | 847 | if (![dict[@"owner"] isKindOfClass:NSDictionary.class]) return nil; |
| 842 | 848 | if (![dict[@"pulls_url"] isKindOfClass:NSString.class]) return nil; |
| 843 | - if (dict[@"pushed_at"] && [dict[@"pushed_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 849 | + if (dict[@"pushed_at"] && [dict[@"pushed_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 850 | + if (dict[@"pushed_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"pushed_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"pushed_at"] substringToIndex:10]]) return nil; | |
| 844 | 851 | if (![dict[@"pushed_at"] isKindOfClass:NSString.class]) return nil; |
| 845 | 852 | if (![dict[@"releases_url"] isKindOfClass:NSString.class]) return nil; |
| 846 | 853 | if (![dict[@"size"] isKindOfClass:NSNumber.class]) return nil; |
| @@ -857,7 +864,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 857 | 864 | if (![dict[@"teams_url"] isKindOfClass:NSString.class]) return nil; |
| 858 | 865 | if (!dict[@"description"]) return nil; |
| 859 | 866 | if (![dict[@"trees_url"] isKindOfClass:NSString.class]) return nil; |
| 860 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 867 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 868 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 861 | 869 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 862 | 870 | if (![dict[@"url"] isKindOfClass:NSString.class]) return nil; |
| 863 | 871 | if (![dict[@"watchers"] isKindOfClass:NSNumber.class]) return nil; |
Mphpdefault / TopLevel.php+32 −0
| @@ -89,6 +89,10 @@ class TopLevel { | ||
| 89 | 89 | */ |
| 90 | 90 | public static function fromCreatedAt(string $value): DateTime { |
| 91 | 91 | $tmp = new DateTime($value); |
| 92 | + $errors = DateTime::getLastErrors(); | |
| 93 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 94 | + throw new Exception('Invalid date-time'); | |
| 95 | + } | |
| 92 | 96 | if (!is_a($tmp, 'DateTime')) { |
| 93 | 97 | throw new Exception('Attribute Error:TopLevel::'); |
| 94 | 98 | } |
| @@ -2790,6 +2794,10 @@ class PullRequest { | ||
| 2790 | 2794 | */ |
| 2791 | 2795 | public static function fromClosedAt(string $value): DateTime { |
| 2792 | 2796 | $tmp = new DateTime($value); |
| 2797 | + $errors = DateTime::getLastErrors(); | |
| 2798 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 2799 | + throw new Exception('Invalid date-time'); | |
| 2800 | + } | |
| 2793 | 2801 | if (!is_a($tmp, 'DateTime')) { |
| 2794 | 2802 | throw new Exception('Attribute Error:PullRequest::'); |
| 2795 | 2803 | } |
| @@ -3032,6 +3040,10 @@ class PullRequest { | ||
| 3032 | 3040 | */ |
| 3033 | 3041 | public static function fromCreatedAt(string $value): DateTime { |
| 3034 | 3042 | $tmp = new DateTime($value); |
| 3043 | + $errors = DateTime::getLastErrors(); | |
| 3044 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 3045 | + throw new Exception('Invalid date-time'); | |
| 3046 | + } | |
| 3035 | 3047 | if (!is_a($tmp, 'DateTime')) { |
| 3036 | 3048 | throw new Exception('Attribute Error:PullRequest::'); |
| 3037 | 3049 | } |
| @@ -3702,6 +3714,10 @@ class PullRequest { | ||
| 3702 | 3714 | */ |
| 3703 | 3715 | public static function fromMergedAt(string $value): DateTime { |
| 3704 | 3716 | $tmp = new DateTime($value); |
| 3717 | + $errors = DateTime::getLastErrors(); | |
| 3718 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 3719 | + throw new Exception('Invalid date-time'); | |
| 3720 | + } | |
| 3705 | 3721 | if (!is_a($tmp, 'DateTime')) { |
| 3706 | 3722 | throw new Exception('Attribute Error:PullRequest::'); |
| 3707 | 3723 | } |
| @@ -4338,6 +4354,10 @@ class PullRequest { | ||
| 4338 | 4354 | */ |
| 4339 | 4355 | public static function fromUpdatedAt(string $value): DateTime { |
| 4340 | 4356 | $tmp = new DateTime($value); |
| 4357 | + $errors = DateTime::getLastErrors(); | |
| 4358 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 4359 | + throw new Exception('Invalid date-time'); | |
| 4360 | + } | |
| 4341 | 4361 | if (!is_a($tmp, 'DateTime')) { |
| 4342 | 4362 | throw new Exception('Attribute Error:PullRequest::'); |
| 4343 | 4363 | } |
| @@ -5873,6 +5893,10 @@ class BaseRepo { | ||
| 5873 | 5893 | */ |
| 5874 | 5894 | public static function fromCreatedAt(string $value): DateTime { |
| 5875 | 5895 | $tmp = new DateTime($value); |
| 5896 | + $errors = DateTime::getLastErrors(); | |
| 5897 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 5898 | + throw new Exception('Invalid date-time'); | |
| 5899 | + } | |
| 5876 | 5900 | if (!is_a($tmp, 'DateTime')) { |
| 5877 | 5901 | throw new Exception('Attribute Error:BaseRepo::'); |
| 5878 | 5902 | } |
| @@ -7817,6 +7841,10 @@ class BaseRepo { | ||
| 7817 | 7841 | */ |
| 7818 | 7842 | public static function fromPushedAt(string $value): DateTime { |
| 7819 | 7843 | $tmp = new DateTime($value); |
| 7844 | + $errors = DateTime::getLastErrors(); | |
| 7845 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 7846 | + throw new Exception('Invalid date-time'); | |
| 7847 | + } | |
| 7820 | 7848 | if (!is_a($tmp, 'DateTime')) { |
| 7821 | 7849 | throw new Exception('Attribute Error:BaseRepo::'); |
| 7822 | 7850 | } |
| @@ -8435,6 +8463,10 @@ class BaseRepo { | ||
| 8435 | 8463 | */ |
| 8436 | 8464 | public static function fromUpdatedAt(string $value): DateTime { |
| 8437 | 8465 | $tmp = new DateTime($value); |
| 8466 | + $errors = DateTime::getLastErrors(); | |
| 8467 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 8468 | + throw new Exception('Invalid date-time'); | |
| 8469 | + } | |
| 8438 | 8470 | if (!is_a($tmp, 'DateTime')) { |
| 8439 | 8471 | throw new Exception('Attribute Error:BaseRepo::'); |
| 8440 | 8472 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -1242,7 +1242,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 1242 | 1242 | let decoder = JSONDecoder() |
| 1243 | 1243 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 1244 | 1244 | let container = try decoder.singleValueContainer() |
| 1245 | - let dateStr = try container.decode(String.self) | |
| 1245 | + let dateStr = try container.decode(String.self).uppercased() | |
| 1246 | 1246 | |
| 1247 | 1247 | let formatter = DateFormatter() |
| 1248 | 1248 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/0b91a.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -355,7 +355,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 355 | 355 | let decoder = JSONDecoder() |
| 356 | 356 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 357 | 357 | let container = try decoder.singleValueContainer() |
| 358 | - let dateStr = try container.decode(String.self) | |
| 358 | + let dateStr = try container.decode(String.self).uppercased() | |
| 359 | 359 | |
| 360 | 360 | let formatter = DateFormatter() |
| 361 | 361 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/0cffa.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -731,7 +731,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 731 | 731 | let decoder = JSONDecoder() |
| 732 | 732 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 733 | 733 | let container = try decoder.singleValueContainer() |
| 734 | - let dateStr = try container.decode(String.self) | |
| 734 | + let dateStr = try container.decode(String.self).uppercased() | |
| 735 | 735 | |
| 736 | 736 | let formatter = DateFormatter() |
| 737 | 737 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/0e0c2.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -526,7 +526,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 526 | 526 | let decoder = JSONDecoder() |
| 527 | 527 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 528 | 528 | let container = try decoder.singleValueContainer() |
| 529 | - let dateStr = try container.decode(String.self) | |
| 529 | + let dateStr = try container.decode(String.self).uppercased() | |
| 530 | 530 | |
| 531 | 531 | let formatter = DateFormatter() |
| 532 | 532 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/0fecf.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/10be4.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -348,7 +348,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 348 | 348 | let decoder = JSONDecoder() |
| 349 | 349 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 350 | 350 | let container = try decoder.singleValueContainer() |
| 351 | - let dateStr = try container.decode(String.self) | |
| 351 | + let dateStr = try container.decode(String.self).uppercased() | |
| 352 | 352 | |
| 353 | 353 | let formatter = DateFormatter() |
| 354 | 354 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/112b5.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -166,7 +166,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 166 | 166 | let decoder = JSONDecoder() |
| 167 | 167 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 168 | 168 | let container = try decoder.singleValueContainer() |
| 169 | - let dateStr = try container.decode(String.self) | |
| 169 | + let dateStr = try container.decode(String.self).uppercased() | |
| 170 | 170 | |
| 171 | 171 | let formatter = DateFormatter() |
| 172 | 172 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/127a1.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -730,7 +730,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 730 | 730 | let decoder = JSONDecoder() |
| 731 | 731 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 732 | 732 | let container = try decoder.singleValueContainer() |
| 733 | - let dateStr = try container.decode(String.self) | |
| 733 | + let dateStr = try container.decode(String.self).uppercased() | |
| 734 | 734 | |
| 735 | 735 | let formatter = DateFormatter() |
| 736 | 736 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/13d8d.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -262,7 +262,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 262 | 262 | let decoder = JSONDecoder() |
| 263 | 263 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 264 | 264 | let container = try decoder.singleValueContainer() |
| 265 | - let dateStr = try container.decode(String.self) | |
| 265 | + let dateStr = try container.decode(String.self).uppercased() | |
| 266 | 266 | |
| 267 | 267 | let formatter = DateFormatter() |
| 268 | 268 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/14d38.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -111,7 +111,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 111 | 111 | let decoder = JSONDecoder() |
| 112 | 112 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 113 | 113 | let container = try decoder.singleValueContainer() |
| 114 | - let dateStr = try container.decode(String.self) | |
| 114 | + let dateStr = try container.decode(String.self).uppercased() | |
| 115 | 115 | |
| 116 | 116 | let formatter = DateFormatter() |
| 117 | 117 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/167d6.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/16bc5.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -711,7 +711,7 @@ namespace quicktype { | ||
| 711 | 711 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 712 | 712 | if (j.find("count") != j.end() && !j.at("count").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 713 | 713 | x.set_count(j.at("count").get<int64_t>()); |
| 714 | - if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 714 | + if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 715 | 715 | x.set_created(j.at("created").get<std::string>()); |
| 716 | 716 | x.set_lang(j.at("lang").get<std::string>()); |
| 717 | 717 | x.set_results(j.at("results").get<Results>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -217,7 +217,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 217 | 217 | if (self = [super init]) { |
| 218 | 218 | if (![dict[@"count"] isKindOfClass:NSNumber.class]) return nil; |
| 219 | 219 | if ([dict[@"count"] doubleValue] != [dict[@"count"] longLongValue]) return nil; |
| 220 | - if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 220 | + if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 221 | + if (dict[@"created"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created"] substringToIndex:10]]) return nil; | |
| 221 | 222 | if (![dict[@"created"] isKindOfClass:NSString.class]) return nil; |
| 222 | 223 | if (![dict[@"lang"] isKindOfClass:NSString.class]) return nil; |
| 223 | 224 | if (![dict[@"results"] isKindOfClass:NSDictionary.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -178,6 +178,10 @@ class Query { | ||
| 178 | 178 | */ |
| 179 | 179 | public static function fromCreated(string $value): DateTime { |
| 180 | 180 | $tmp = new DateTime($value); |
| 181 | + $errors = DateTime::getLastErrors(); | |
| 182 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 183 | + throw new Exception('Invalid date-time'); | |
| 184 | + } | |
| 181 | 185 | if (!is_a($tmp, 'DateTime')) { |
| 182 | 186 | throw new Exception('Attribute Error:Query::'); |
| 183 | 187 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -811,7 +811,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 811 | 811 | let decoder = JSONDecoder() |
| 812 | 812 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 813 | 813 | let container = try decoder.singleValueContainer() |
| 814 | - let dateStr = try container.decode(String.self) | |
| 814 | + let dateStr = try container.decode(String.self).uppercased() | |
| 815 | 815 | |
| 816 | 816 | let formatter = DateFormatter() |
| 817 | 817 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/176f1.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -267,7 +267,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 267 | 267 | let decoder = JSONDecoder() |
| 268 | 268 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 269 | 269 | let container = try decoder.singleValueContainer() |
| 270 | - let dateStr = try container.decode(String.self) | |
| 270 | + let dateStr = try container.decode(String.self).uppercased() | |
| 271 | 271 | |
| 272 | 272 | let formatter = DateFormatter() |
| 273 | 273 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/1a7f5.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -106,7 +106,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 106 | 106 | let decoder = JSONDecoder() |
| 107 | 107 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 108 | 108 | let container = try decoder.singleValueContainer() |
| 109 | - let dateStr = try container.decode(String.self) | |
| 109 | + let dateStr = try container.decode(String.self).uppercased() | |
| 110 | 110 | |
| 111 | 111 | let formatter = DateFormatter() |
| 112 | 112 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/1b28c.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/1b409.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -445,7 +445,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 445 | 445 | let decoder = JSONDecoder() |
| 446 | 446 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 447 | 447 | let container = try decoder.singleValueContainer() |
| 448 | - let dateStr = try container.decode(String.self) | |
| 448 | + let dateStr = try container.decode(String.self).uppercased() | |
| 449 | 449 | |
| 450 | 450 | let formatter = DateFormatter() |
| 451 | 451 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/2465e.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -683,7 +683,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 683 | 683 | let decoder = JSONDecoder() |
| 684 | 684 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 685 | 685 | let container = try decoder.singleValueContainer() |
| 686 | - let dateStr = try container.decode(String.self) | |
| 686 | + let dateStr = try container.decode(String.self).uppercased() | |
| 687 | 687 | |
| 688 | 688 | let formatter = DateFormatter() |
| 689 | 689 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/24f52.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -271,7 +271,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 271 | 271 | let decoder = JSONDecoder() |
| 272 | 272 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 273 | 273 | let container = try decoder.singleValueContainer() |
| 274 | - let dateStr = try container.decode(String.self) | |
| 274 | + let dateStr = try container.decode(String.self).uppercased() | |
| 275 | 275 | |
| 276 | 276 | let formatter = DateFormatter() |
| 277 | 277 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/262f0.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -716,7 +716,7 @@ namespace quicktype { | ||
| 716 | 716 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 717 | 717 | if (j.find("count") != j.end() && !j.at("count").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 718 | 718 | x.set_count(j.at("count").get<int64_t>()); |
| 719 | - if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 719 | + if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 720 | 720 | x.set_created(j.at("created").get<std::string>()); |
| 721 | 721 | x.set_lang(j.at("lang").get<std::string>()); |
| 722 | 722 | x.set_results(j.at("results").get<Results>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -246,7 +246,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 246 | 246 | if (self = [super init]) { |
| 247 | 247 | if (![dict[@"count"] isKindOfClass:NSNumber.class]) return nil; |
| 248 | 248 | if ([dict[@"count"] doubleValue] != [dict[@"count"] longLongValue]) return nil; |
| 249 | - if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 249 | + if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 250 | + if (dict[@"created"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created"] substringToIndex:10]]) return nil; | |
| 250 | 251 | if (![dict[@"created"] isKindOfClass:NSString.class]) return nil; |
| 251 | 252 | if (![dict[@"lang"] isKindOfClass:NSString.class]) return nil; |
| 252 | 253 | if (![dict[@"results"] isKindOfClass:NSDictionary.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -178,6 +178,10 @@ class Query { | ||
| 178 | 178 | */ |
| 179 | 179 | public static function fromCreated(string $value): DateTime { |
| 180 | 180 | $tmp = new DateTime($value); |
| 181 | + $errors = DateTime::getLastErrors(); | |
| 182 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 183 | + throw new Exception('Invalid date-time'); | |
| 184 | + } | |
| 181 | 185 | if (!is_a($tmp, 'DateTime')) { |
| 182 | 186 | throw new Exception('Attribute Error:Query::'); |
| 183 | 187 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -817,7 +817,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 817 | 817 | let decoder = JSONDecoder() |
| 818 | 818 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 819 | 819 | let container = try decoder.singleValueContainer() |
| 820 | - let dateStr = try container.decode(String.self) | |
| 820 | + let dateStr = try container.decode(String.self).uppercased() | |
| 821 | 821 | |
| 822 | 822 | let formatter = DateFormatter() |
| 823 | 823 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/26b49.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -730,7 +730,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 730 | 730 | let decoder = JSONDecoder() |
| 731 | 731 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 732 | 732 | let container = try decoder.singleValueContainer() |
| 733 | - let dateStr = try container.decode(String.self) | |
| 733 | + let dateStr = try container.decode(String.self).uppercased() | |
| 734 | 734 | |
| 735 | 735 | let formatter = DateFormatter() |
| 736 | 736 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/26c9c.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -1474,7 +1474,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 1474 | 1474 | let decoder = JSONDecoder() |
| 1475 | 1475 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 1476 | 1476 | let container = try decoder.singleValueContainer() |
| 1477 | - let dateStr = try container.decode(String.self) | |
| 1477 | + let dateStr = try container.decode(String.self).uppercased() | |
| 1478 | 1478 | |
| 1479 | 1479 | let formatter = DateFormatter() |
| 1480 | 1480 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/27332.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -882,7 +882,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 882 | 882 | let decoder = JSONDecoder() |
| 883 | 883 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 884 | 884 | let container = try decoder.singleValueContainer() |
| 885 | - let dateStr = try container.decode(String.self) | |
| 885 | + let dateStr = try container.decode(String.self).uppercased() | |
| 886 | 886 | |
| 887 | 887 | let formatter = DateFormatter() |
| 888 | 888 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/29f47.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -816,7 +816,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 816 | 816 | let decoder = JSONDecoder() |
| 817 | 817 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 818 | 818 | let container = try decoder.singleValueContainer() |
| 819 | - let dateStr = try container.decode(String.self) | |
| 819 | + let dateStr = try container.decode(String.self).uppercased() | |
| 820 | 820 | |
| 821 | 821 | let formatter = DateFormatter() |
| 822 | 822 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/2d4e2.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -471,7 +471,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 471 | 471 | let decoder = JSONDecoder() |
| 472 | 472 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 473 | 473 | let container = try decoder.singleValueContainer() |
| 474 | - let dateStr = try container.decode(String.self) | |
| 474 | + let dateStr = try container.decode(String.self).uppercased() | |
| 475 | 475 | |
| 476 | 476 | let formatter = DateFormatter() |
| 477 | 477 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/2df80.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -300,7 +300,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 300 | 300 | let decoder = JSONDecoder() |
| 301 | 301 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 302 | 302 | let container = try decoder.singleValueContainer() |
| 303 | - let dateStr = try container.decode(String.self) | |
| 303 | + let dateStr = try container.decode(String.self).uppercased() | |
| 304 | 304 | |
| 305 | 305 | let formatter = DateFormatter() |
| 306 | 306 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/31189.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -231,7 +231,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 231 | 231 | let decoder = JSONDecoder() |
| 232 | 232 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 233 | 233 | let container = try decoder.singleValueContainer() |
| 234 | - let dateStr = try container.decode(String.self) | |
| 234 | + let dateStr = try container.decode(String.self).uppercased() | |
| 235 | 235 | |
| 236 | 236 | let formatter = DateFormatter() |
| 237 | 237 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/32431.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -402,7 +402,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 402 | 402 | let decoder = JSONDecoder() |
| 403 | 403 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 404 | 404 | let container = try decoder.singleValueContainer() |
| 405 | - let dateStr = try container.decode(String.self) | |
| 405 | + let dateStr = try container.decode(String.self).uppercased() | |
| 406 | 406 | |
| 407 | 407 | let formatter = DateFormatter() |
| 408 | 408 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
2 generated files · +5 −1test/inputs/json/misc/32d5c.json
Mphpdefault / TopLevel.php+4 −0
| @@ -42,6 +42,10 @@ class TopLevel { | ||
| 42 | 42 | public static function fromBirthDate(?string $value): ?DateTime { |
| 43 | 43 | if (!is_null($value)) { |
| 44 | 44 | $tmp = new DateTime($value); |
| 45 | + $errors = DateTime::getLastErrors(); | |
| 46 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 47 | + throw new Exception('Invalid date-time'); | |
| 48 | + } | |
| 45 | 49 | if (!is_a($tmp, 'DateTime')) { |
| 46 | 50 | throw new Exception('Attribute Error:TopLevel::'); |
| 47 | 51 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -110,7 +110,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 110 | 110 | let decoder = JSONDecoder() |
| 111 | 111 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 112 | 112 | let container = try decoder.singleValueContainer() |
| 113 | - let dateStr = try container.decode(String.self) | |
| 113 | + let dateStr = try container.decode(String.self).uppercased() | |
| 114 | 114 | |
| 115 | 115 | let formatter = DateFormatter() |
| 116 | 116 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +43 −13test/inputs/json/misc/337ed.json
Mcplusplusdefault / quicktype.hpp+6 −6
| @@ -386,13 +386,13 @@ namespace quicktype { | ||
| 386 | 386 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 387 | 387 | if (j.find("amount") != j.end() && !j.at("amount").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 388 | 388 | x.set_amount(j.at("amount").get<int64_t>()); |
| 389 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 389 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 390 | 390 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 391 | 391 | x.set_id(j.at("id").get<std::string>()); |
| 392 | 392 | x.set_name(j.at("name").get<std::string>()); |
| 393 | 393 | x.set_status(j.at("status").get<Status>()); |
| 394 | 394 | x.set_type(j.at("type").get<CustomIncomeType>()); |
| 395 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 395 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 396 | 396 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 397 | 397 | x.set_uri(j.at("uri").get<std::string>()); |
| 398 | 398 | } |
| @@ -417,12 +417,12 @@ namespace quicktype { | ||
| 417 | 417 | x.set_cost_max(get_stack_optional<int64_t>(j, "cost_max")); |
| 418 | 418 | j.at("cost_min"); |
| 419 | 419 | x.set_cost_min(get_stack_optional<int64_t>(j, "cost_min")); |
| 420 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 420 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 421 | 421 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 422 | 422 | x.set_custom_incomes(j.at("customIncomes").get<std::vector<CustomIncome>>()); |
| 423 | 423 | x.set_direct_rep_costs_max(get_untyped(j, "direct_rep_costs_max")); |
| 424 | 424 | x.set_direct_rep_costs_min(get_untyped(j, "direct_rep_costs_min")); |
| 425 | - if (j.find("end_date") != j.end() && !std::regex_match(j.at("end_date").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 425 | + if (j.find("end_date") != j.end() && !std::regex_match(j.at("end_date").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 426 | 426 | x.set_end_date(j.at("end_date").get<std::string>()); |
| 427 | 427 | if (j.find("eur_sources_grants") != j.end() && !j.at("eur_sources_grants").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 428 | 428 | x.set_eur_sources_grants(j.at("eur_sources_grants").get<int64_t>()); |
| @@ -451,7 +451,7 @@ namespace quicktype { | ||
| 451 | 451 | j.at("public_financing_total"); |
| 452 | 452 | x.set_public_financing_total(get_stack_optional<int64_t>(j, "public_financing_total")); |
| 453 | 453 | x.set_representative(j.at("representative").get<std::string>()); |
| 454 | - if (j.find("start_date") != j.end() && !std::regex_match(j.at("start_date").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 454 | + if (j.find("start_date") != j.end() && !std::regex_match(j.at("start_date").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 455 | 455 | x.set_start_date(j.at("start_date").get<std::string>()); |
| 456 | 456 | x.set_status(j.at("status").get<Status>()); |
| 457 | 457 | j.at("total_budget"); |
| @@ -463,7 +463,7 @@ namespace quicktype { | ||
| 463 | 463 | j.at("turnover_min"); |
| 464 | 464 | x.set_turnover_min(get_stack_optional<int64_t>(j, "turnover_min")); |
| 465 | 465 | x.set_type(j.at("type").get<ResultType>()); |
| 466 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 466 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 467 | 467 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 468 | 468 | x.set_uri(j.at("uri").get<std::string>()); |
| 469 | 469 | } |
Mobjective-cdefault / QTTopLevel.m+12 −6
| @@ -344,12 +344,14 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 344 | 344 | if (!dict[@"cost_absolute"]) return nil; |
| 345 | 345 | if (!dict[@"cost_max"]) return nil; |
| 346 | 346 | if (!dict[@"cost_min"]) return nil; |
| 347 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 347 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 348 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 348 | 349 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 349 | 350 | if (![dict[@"customIncomes"] isKindOfClass:NSArray.class]) return nil; |
| 350 | 351 | if (!dict[@"direct_rep_costs_max"]) return nil; |
| 351 | 352 | if (!dict[@"direct_rep_costs_min"]) return nil; |
| 352 | - if (dict[@"end_date"] && [dict[@"end_date"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 353 | + if (dict[@"end_date"] && [dict[@"end_date"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 354 | + if (dict[@"end_date"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"end_date"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"end_date"] substringToIndex:10]]) return nil; | |
| 353 | 355 | if (![dict[@"end_date"] isKindOfClass:NSString.class]) return nil; |
| 354 | 356 | if (![dict[@"eur_sources_grants"] isKindOfClass:NSNumber.class]) return nil; |
| 355 | 357 | if ([dict[@"eur_sources_grants"] doubleValue] != [dict[@"eur_sources_grants"] longLongValue]) return nil; |
| @@ -367,7 +369,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 367 | 369 | if (!dict[@"public_financing_national"]) return nil; |
| 368 | 370 | if (!dict[@"public_financing_total"]) return nil; |
| 369 | 371 | if (![dict[@"representative"] isKindOfClass:NSString.class]) return nil; |
| 370 | - if (dict[@"start_date"] && [dict[@"start_date"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 372 | + if (dict[@"start_date"] && [dict[@"start_date"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 373 | + if (dict[@"start_date"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"start_date"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"start_date"] substringToIndex:10]]) return nil; | |
| 371 | 374 | if (![dict[@"start_date"] isKindOfClass:NSString.class]) return nil; |
| 372 | 375 | if (![dict[@"status"] isKindOfClass:NSString.class]) return nil; |
| 373 | 376 | if (!dict[@"new_organisation"]) return nil; |
| @@ -376,7 +379,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 376 | 379 | if (!dict[@"turnover_max"]) return nil; |
| 377 | 380 | if (!dict[@"turnover_min"]) return nil; |
| 378 | 381 | if (![dict[@"type"] isKindOfClass:NSString.class]) return nil; |
| 379 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 382 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 383 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 380 | 384 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 381 | 385 | if (![dict[@"uri"] isKindOfClass:NSString.class]) return nil; |
| 382 | 386 | [self setValuesForKeysWithDictionary:dict]; |
| @@ -447,13 +451,15 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 447 | 451 | if (self = [super init]) { |
| 448 | 452 | if (![dict[@"amount"] isKindOfClass:NSNumber.class]) return nil; |
| 449 | 453 | if ([dict[@"amount"] doubleValue] != [dict[@"amount"] longLongValue]) return nil; |
| 450 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 454 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 455 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 451 | 456 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 452 | 457 | if (![dict[@"id"] isKindOfClass:NSString.class]) return nil; |
| 453 | 458 | if (![dict[@"name"] isKindOfClass:NSString.class]) return nil; |
| 454 | 459 | if (![dict[@"status"] isKindOfClass:NSString.class]) return nil; |
| 455 | 460 | if (![dict[@"type"] isKindOfClass:NSString.class]) return nil; |
| 456 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 461 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 462 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 457 | 463 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 458 | 464 | if (![dict[@"uri"] isKindOfClass:NSString.class]) return nil; |
| 459 | 465 | [self setValuesForKeysWithDictionary:dict]; |
Mphpdefault / TopLevel.php+24 −0
| @@ -785,6 +785,10 @@ class Result { | ||
| 785 | 785 | */ |
| 786 | 786 | public static function fromCreatedAt(string $value): DateTime { |
| 787 | 787 | $tmp = new DateTime($value); |
| 788 | + $errors = DateTime::getLastErrors(); | |
| 789 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 790 | + throw new Exception('Invalid date-time'); | |
| 791 | + } | |
| 788 | 792 | if (!is_a($tmp, 'DateTime')) { |
| 789 | 793 | throw new Exception('Attribute Error:Result::'); |
| 790 | 794 | } |
| @@ -998,6 +1002,10 @@ class Result { | ||
| 998 | 1002 | */ |
| 999 | 1003 | public static function fromEndDate(string $value): DateTime { |
| 1000 | 1004 | $tmp = new DateTime($value); |
| 1005 | + $errors = DateTime::getLastErrors(); | |
| 1006 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 1007 | + throw new Exception('Invalid date-time'); | |
| 1008 | + } | |
| 1001 | 1009 | if (!is_a($tmp, 'DateTime')) { |
| 1002 | 1010 | throw new Exception('Attribute Error:Result::'); |
| 1003 | 1011 | } |
| @@ -1860,6 +1868,10 @@ class Result { | ||
| 1860 | 1868 | */ |
| 1861 | 1869 | public static function fromStartDate(string $value): DateTime { |
| 1862 | 1870 | $tmp = new DateTime($value); |
| 1871 | + $errors = DateTime::getLastErrors(); | |
| 1872 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 1873 | + throw new Exception('Invalid date-time'); | |
| 1874 | + } | |
| 1863 | 1875 | if (!is_a($tmp, 'DateTime')) { |
| 1864 | 1876 | throw new Exception('Attribute Error:Result::'); |
| 1865 | 1877 | } |
| @@ -2238,6 +2250,10 @@ class Result { | ||
| 2238 | 2250 | */ |
| 2239 | 2251 | public static function fromUpdatedAt(string $value): DateTime { |
| 2240 | 2252 | $tmp = new DateTime($value); |
| 2253 | + $errors = DateTime::getLastErrors(); | |
| 2254 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 2255 | + throw new Exception('Invalid date-time'); | |
| 2256 | + } | |
| 2241 | 2257 | if (!is_a($tmp, 'DateTime')) { |
| 2242 | 2258 | throw new Exception('Attribute Error:Result::'); |
| 2243 | 2259 | } |
| @@ -2678,6 +2694,10 @@ class CustomIncome { | ||
| 2678 | 2694 | */ |
| 2679 | 2695 | public static function fromCreatedAt(string $value): DateTime { |
| 2680 | 2696 | $tmp = new DateTime($value); |
| 2697 | + $errors = DateTime::getLastErrors(); | |
| 2698 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 2699 | + throw new Exception('Invalid date-time'); | |
| 2700 | + } | |
| 2681 | 2701 | if (!is_a($tmp, 'DateTime')) { |
| 2682 | 2702 | throw new Exception('Attribute Error:CustomIncome::'); |
| 2683 | 2703 | } |
| @@ -2922,6 +2942,10 @@ class CustomIncome { | ||
| 2922 | 2942 | */ |
| 2923 | 2943 | public static function fromUpdatedAt(string $value): DateTime { |
| 2924 | 2944 | $tmp = new DateTime($value); |
| 2945 | + $errors = DateTime::getLastErrors(); | |
| 2946 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 2947 | + throw new Exception('Invalid date-time'); | |
| 2948 | + } | |
| 2925 | 2949 | if (!is_a($tmp, 'DateTime')) { |
| 2926 | 2950 | throw new Exception('Attribute Error:CustomIncome::'); |
| 2927 | 2951 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -378,7 +378,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 378 | 378 | let decoder = JSONDecoder() |
| 379 | 379 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 380 | 380 | let container = try decoder.singleValueContainer() |
| 381 | - let dateStr = try container.decode(String.self) | |
| 381 | + let dateStr = try container.decode(String.self).uppercased() | |
| 382 | 382 | |
| 383 | 383 | let formatter = DateFormatter() |
| 384 | 384 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/33d2e.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -306,7 +306,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 306 | 306 | let decoder = JSONDecoder() |
| 307 | 307 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 308 | 308 | let container = try decoder.singleValueContainer() |
| 309 | - let dateStr = try container.decode(String.self) | |
| 309 | + let dateStr = try container.decode(String.self).uppercased() | |
| 310 | 310 | |
| 311 | 311 | let formatter = DateFormatter() |
| 312 | 312 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/34702.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -418,7 +418,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 418 | 418 | let decoder = JSONDecoder() |
| 419 | 419 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 420 | 420 | let container = try decoder.singleValueContainer() |
| 421 | - let dateStr = try container.decode(String.self) | |
| 421 | + let dateStr = try container.decode(String.self).uppercased() | |
| 422 | 422 | |
| 423 | 423 | let formatter = DateFormatter() |
| 424 | 424 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/3536b.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -270,7 +270,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 270 | 270 | let decoder = JSONDecoder() |
| 271 | 271 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 272 | 272 | let container = try decoder.singleValueContainer() |
| 273 | - let dateStr = try container.decode(String.self) | |
| 273 | + let dateStr = try container.decode(String.self).uppercased() | |
| 274 | 274 | |
| 275 | 275 | let formatter = DateFormatter() |
| 276 | 276 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/3659d.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/36d5d.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -271,7 +271,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 271 | 271 | let decoder = JSONDecoder() |
| 272 | 272 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 273 | 273 | let container = try decoder.singleValueContainer() |
| 274 | - let dateStr = try container.decode(String.self) | |
| 274 | + let dateStr = try container.decode(String.self).uppercased() | |
| 275 | 275 | |
| 276 | 276 | let formatter = DateFormatter() |
| 277 | 277 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/3a6b3.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -271,7 +271,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 271 | 271 | let decoder = JSONDecoder() |
| 272 | 272 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 273 | 273 | let container = try decoder.singleValueContainer() |
| 274 | - let dateStr = try container.decode(String.self) | |
| 274 | + let dateStr = try container.decode(String.self).uppercased() | |
| 275 | 275 | |
| 276 | 276 | let formatter = DateFormatter() |
| 277 | 277 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/3e9a3.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -267,7 +267,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 267 | 267 | let decoder = JSONDecoder() |
| 268 | 268 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 269 | 269 | let container = try decoder.singleValueContainer() |
| 270 | - let dateStr = try container.decode(String.self) | |
| 270 | + let dateStr = try container.decode(String.self).uppercased() | |
| 271 | 271 | |
| 272 | 272 | let formatter = DateFormatter() |
| 273 | 273 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/3f1ce.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -716,7 +716,7 @@ namespace quicktype { | ||
| 716 | 716 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 717 | 717 | if (j.find("count") != j.end() && !j.at("count").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 718 | 718 | x.set_count(j.at("count").get<int64_t>()); |
| 719 | - if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 719 | + if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 720 | 720 | x.set_created(j.at("created").get<std::string>()); |
| 721 | 721 | x.set_lang(j.at("lang").get<std::string>()); |
| 722 | 722 | x.set_results(j.at("results").get<Results>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -242,7 +242,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 242 | 242 | if (self = [super init]) { |
| 243 | 243 | if (![dict[@"count"] isKindOfClass:NSNumber.class]) return nil; |
| 244 | 244 | if ([dict[@"count"] doubleValue] != [dict[@"count"] longLongValue]) return nil; |
| 245 | - if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 245 | + if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 246 | + if (dict[@"created"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created"] substringToIndex:10]]) return nil; | |
| 246 | 247 | if (![dict[@"created"] isKindOfClass:NSString.class]) return nil; |
| 247 | 248 | if (![dict[@"lang"] isKindOfClass:NSString.class]) return nil; |
| 248 | 249 | if (![dict[@"results"] isKindOfClass:NSDictionary.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -178,6 +178,10 @@ class Query { | ||
| 178 | 178 | */ |
| 179 | 179 | public static function fromCreated(string $value): DateTime { |
| 180 | 180 | $tmp = new DateTime($value); |
| 181 | + $errors = DateTime::getLastErrors(); | |
| 182 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 183 | + throw new Exception('Invalid date-time'); | |
| 184 | + } | |
| 181 | 185 | if (!is_a($tmp, 'DateTime')) { |
| 182 | 186 | throw new Exception('Attribute Error:Query::'); |
| 183 | 187 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -815,7 +815,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 815 | 815 | let decoder = JSONDecoder() |
| 816 | 816 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 817 | 817 | let container = try decoder.singleValueContainer() |
| 818 | - let dateStr = try container.decode(String.self) | |
| 818 | + let dateStr = try container.decode(String.self).uppercased() | |
| 819 | 819 | |
| 820 | 820 | let formatter = DateFormatter() |
| 821 | 821 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/421d4.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -877,7 +877,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 877 | 877 | let decoder = JSONDecoder() |
| 878 | 878 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 879 | 879 | let container = try decoder.singleValueContainer() |
| 880 | - let dateStr = try container.decode(String.self) | |
| 880 | + let dateStr = try container.decode(String.self).uppercased() | |
| 881 | 881 | |
| 882 | 882 | let formatter = DateFormatter() |
| 883 | 883 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/437e7.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -718,7 +718,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 718 | 718 | let decoder = JSONDecoder() |
| 719 | 719 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 720 | 720 | let container = try decoder.singleValueContainer() |
| 721 | - let dateStr = try container.decode(String.self) | |
| 721 | + let dateStr = try container.decode(String.self).uppercased() | |
| 722 | 722 | |
| 723 | 723 | let formatter = DateFormatter() |
| 724 | 724 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/43970.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -90,7 +90,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 90 | 90 | let decoder = JSONDecoder() |
| 91 | 91 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 92 | 92 | let container = try decoder.singleValueContainer() |
| 93 | - let dateStr = try container.decode(String.self) | |
| 93 | + let dateStr = try container.decode(String.self).uppercased() | |
| 94 | 94 | |
| 95 | 95 | let formatter = DateFormatter() |
| 96 | 96 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/43eaf.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/458db.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -355,7 +355,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 355 | 355 | let decoder = JSONDecoder() |
| 356 | 356 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 357 | 357 | let container = try decoder.singleValueContainer() |
| 358 | - let dateStr = try container.decode(String.self) | |
| 358 | + let dateStr = try container.decode(String.self).uppercased() | |
| 359 | 359 | |
| 360 | 360 | let formatter = DateFormatter() |
| 361 | 361 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/4961a.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/4a0d7.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/4a455.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -343,7 +343,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 343 | 343 | let decoder = JSONDecoder() |
| 344 | 344 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 345 | 345 | let container = try decoder.singleValueContainer() |
| 346 | - let dateStr = try container.decode(String.self) | |
| 346 | + let dateStr = try container.decode(String.self).uppercased() | |
| 347 | 347 | |
| 348 | 348 | let formatter = DateFormatter() |
| 349 | 349 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/4c547.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -711,7 +711,7 @@ namespace quicktype { | ||
| 711 | 711 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 712 | 712 | if (j.find("count") != j.end() && !j.at("count").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 713 | 713 | x.set_count(j.at("count").get<int64_t>()); |
| 714 | - if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 714 | + if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 715 | 715 | x.set_created(j.at("created").get<std::string>()); |
| 716 | 716 | x.set_lang(j.at("lang").get<std::string>()); |
| 717 | 717 | x.set_results(j.at("results").get<Results>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -217,7 +217,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 217 | 217 | if (self = [super init]) { |
| 218 | 218 | if (![dict[@"count"] isKindOfClass:NSNumber.class]) return nil; |
| 219 | 219 | if ([dict[@"count"] doubleValue] != [dict[@"count"] longLongValue]) return nil; |
| 220 | - if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 220 | + if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 221 | + if (dict[@"created"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created"] substringToIndex:10]]) return nil; | |
| 221 | 222 | if (![dict[@"created"] isKindOfClass:NSString.class]) return nil; |
| 222 | 223 | if (![dict[@"lang"] isKindOfClass:NSString.class]) return nil; |
| 223 | 224 | if (![dict[@"results"] isKindOfClass:NSDictionary.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -178,6 +178,10 @@ class Query { | ||
| 178 | 178 | */ |
| 179 | 179 | public static function fromCreated(string $value): DateTime { |
| 180 | 180 | $tmp = new DateTime($value); |
| 181 | + $errors = DateTime::getLastErrors(); | |
| 182 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 183 | + throw new Exception('Invalid date-time'); | |
| 184 | + } | |
| 181 | 185 | if (!is_a($tmp, 'DateTime')) { |
| 182 | 186 | throw new Exception('Attribute Error:Query::'); |
| 183 | 187 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -811,7 +811,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 811 | 811 | let decoder = JSONDecoder() |
| 812 | 812 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 813 | 813 | let container = try decoder.singleValueContainer() |
| 814 | - let dateStr = try container.decode(String.self) | |
| 814 | + let dateStr = try container.decode(String.self).uppercased() | |
| 815 | 815 | |
| 816 | 816 | let formatter = DateFormatter() |
| 817 | 817 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/4d6fb.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -879,7 +879,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 879 | 879 | let decoder = JSONDecoder() |
| 880 | 880 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 881 | 881 | let container = try decoder.singleValueContainer() |
| 882 | - let dateStr = try container.decode(String.self) | |
| 882 | + let dateStr = try container.decode(String.self).uppercased() | |
| 883 | 883 | |
| 884 | 884 | let formatter = DateFormatter() |
| 885 | 885 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/4e336.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/54147.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -178,7 +178,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 178 | 178 | let decoder = JSONDecoder() |
| 179 | 179 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 180 | 180 | let container = try decoder.singleValueContainer() |
| 181 | - let dateStr = try container.decode(String.self) | |
| 181 | + let dateStr = try container.decode(String.self).uppercased() | |
| 182 | 182 | |
| 183 | 183 | let formatter = DateFormatter() |
| 184 | 184 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +15 −5test/inputs/json/misc/54d32.json
Mcplusplusdefault / quicktype.hpp+2 −2
| @@ -153,13 +153,13 @@ namespace quicktype { | ||
| 153 | 153 | |
| 154 | 154 | inline void from_json(const json & j, Result& x) { |
| 155 | 155 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 156 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 156 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 157 | 157 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 158 | 158 | x.set_id(j.at("id").get<std::string>()); |
| 159 | 159 | x.set_person_id(j.at("person_id").get<std::string>()); |
| 160 | 160 | x.set_representative_id(j.at("representative_id").get<std::string>()); |
| 161 | 161 | x.set_status(j.at("status").get<Status>()); |
| 162 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 162 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 163 | 163 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 164 | 164 | } |
Mobjective-cdefault / QTTopLevel.m+4 −2
| @@ -254,13 +254,15 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 254 | 254 | - (instancetype)initWithJSONDictionary:(NSDictionary *)dict |
| 255 | 255 | { |
| 256 | 256 | if (self = [super init]) { |
| 257 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 257 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 258 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 258 | 259 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 259 | 260 | if (![dict[@"id"] isKindOfClass:NSString.class]) return nil; |
| 260 | 261 | if (![dict[@"person_id"] isKindOfClass:NSString.class]) return nil; |
| 261 | 262 | if (![dict[@"representative_id"] isKindOfClass:NSString.class]) return nil; |
| 262 | 263 | if (![dict[@"status"] isKindOfClass:NSString.class]) return nil; |
| 263 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 264 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 265 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 264 | 266 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 265 | 267 | [self setValuesForKeysWithDictionary:dict]; |
| 266 | 268 | _status = [QTStatus withValue:(id)_status]; |
Mphpdefault / TopLevel.php+8 −0
| @@ -536,6 +536,10 @@ class Result { | ||
| 536 | 536 | */ |
| 537 | 537 | public static function fromCreatedAt(string $value): DateTime { |
| 538 | 538 | $tmp = new DateTime($value); |
| 539 | + $errors = DateTime::getLastErrors(); | |
| 540 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 541 | + throw new Exception('Invalid date-time'); | |
| 542 | + } | |
| 539 | 543 | if (!is_a($tmp, 'DateTime')) { |
| 540 | 544 | throw new Exception('Attribute Error:Result::'); |
| 541 | 545 | } |
| @@ -779,6 +783,10 @@ class Result { | ||
| 779 | 783 | */ |
| 780 | 784 | public static function fromUpdatedAt(string $value): DateTime { |
| 781 | 785 | $tmp = new DateTime($value); |
| 786 | + $errors = DateTime::getLastErrors(); | |
| 787 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 788 | + throw new Exception('Invalid date-time'); | |
| 789 | + } | |
| 782 | 790 | if (!is_a($tmp, 'DateTime')) { |
| 783 | 791 | throw new Exception('Attribute Error:Result::'); |
| 784 | 792 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -191,7 +191,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 191 | 191 | let decoder = JSONDecoder() |
| 192 | 192 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 193 | 193 | let container = try decoder.singleValueContainer() |
| 194 | - let dateStr = try container.decode(String.self) | |
| 194 | + let dateStr = try container.decode(String.self).uppercased() | |
| 195 | 195 | |
| 196 | 196 | let formatter = DateFormatter() |
| 197 | 197 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/570ec.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -312,7 +312,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 312 | 312 | let decoder = JSONDecoder() |
| 313 | 313 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 314 | 314 | let container = try decoder.singleValueContainer() |
| 315 | - let dateStr = try container.decode(String.self) | |
| 315 | + let dateStr = try container.decode(String.self).uppercased() | |
| 316 | 316 | |
| 317 | 317 | let formatter = DateFormatter() |
| 318 | 318 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/5dd0d.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -271,7 +271,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 271 | 271 | let decoder = JSONDecoder() |
| 272 | 272 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 273 | 273 | let container = try decoder.singleValueContainer() |
| 274 | - let dateStr = try container.decode(String.self) | |
| 274 | + let dateStr = try container.decode(String.self).uppercased() | |
| 275 | 275 | |
| 276 | 276 | let formatter = DateFormatter() |
| 277 | 277 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/5eae5.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -69,7 +69,7 @@ namespace quicktype { | ||
| 69 | 69 | |
| 70 | 70 | inline void from_json(const json & j, TopLevelElement& x) { |
| 71 | 71 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 72 | - if (j.find("Date") != j.end() && !std::regex_match(j.at("Date").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 72 | + if (j.find("Date") != j.end() && !std::regex_match(j.at("Date").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 73 | 73 | x.set_date(j.at("Date").get<std::string>()); |
| 74 | 74 | if (j.find("ID") != j.end() && !j.at("ID").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 75 | 75 | x.set_id(j.at("ID").get<int64_t>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -82,7 +82,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 82 | 82 | - (instancetype)initWithJSONDictionary:(NSDictionary *)dict |
| 83 | 83 | { |
| 84 | 84 | if (self = [super init]) { |
| 85 | - if (dict[@"Date"] && [dict[@"Date"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 85 | + if (dict[@"Date"] && [dict[@"Date"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 86 | + if (dict[@"Date"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"Date"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"Date"] substringToIndex:10]]) return nil; | |
| 86 | 87 | if (![dict[@"Date"] isKindOfClass:NSString.class]) return nil; |
| 87 | 88 | if (![dict[@"ID"] isKindOfClass:NSNumber.class]) return nil; |
| 88 | 89 | if ([dict[@"ID"] doubleValue] != [dict[@"ID"] longLongValue]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -29,6 +29,10 @@ class TopLevel { | ||
| 29 | 29 | */ |
| 30 | 30 | public static function fromDate(string $value): DateTime { |
| 31 | 31 | $tmp = new DateTime($value); |
| 32 | + $errors = DateTime::getLastErrors(); | |
| 33 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 34 | + throw new Exception('Invalid date-time'); | |
| 35 | + } | |
| 32 | 36 | if (!is_a($tmp, 'DateTime')) { |
| 33 | 37 | throw new Exception('Attribute Error:TopLevel::'); |
| 34 | 38 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -94,7 +94,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 94 | 94 | let decoder = JSONDecoder() |
| 95 | 95 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 96 | 96 | let container = try decoder.singleValueContainer() |
| 97 | - let dateStr = try container.decode(String.self) | |
| 97 | + let dateStr = try container.decode(String.self).uppercased() | |
| 98 | 98 | |
| 99 | 99 | let formatter = DateFormatter() |
| 100 | 100 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/5eb20.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -271,7 +271,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 271 | 271 | let decoder = JSONDecoder() |
| 272 | 272 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 273 | 273 | let container = try decoder.singleValueContainer() |
| 274 | - let dateStr = try container.decode(String.self) | |
| 274 | + let dateStr = try container.decode(String.self).uppercased() | |
| 275 | 275 | |
| 276 | 276 | let formatter = DateFormatter() |
| 277 | 277 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/5f3a1.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/5f7fe.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -1464,7 +1464,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 1464 | 1464 | let decoder = JSONDecoder() |
| 1465 | 1465 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 1466 | 1466 | let container = try decoder.singleValueContainer() |
| 1467 | - let dateStr = try container.decode(String.self) | |
| 1467 | + let dateStr = try container.decode(String.self).uppercased() | |
| 1468 | 1468 | |
| 1469 | 1469 | let formatter = DateFormatter() |
| 1470 | 1470 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/617e8.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -1460,7 +1460,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 1460 | 1460 | let decoder = JSONDecoder() |
| 1461 | 1461 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 1462 | 1462 | let container = try decoder.singleValueContainer() |
| 1463 | - let dateStr = try container.decode(String.self) | |
| 1463 | + let dateStr = try container.decode(String.self).uppercased() | |
| 1464 | 1464 | |
| 1465 | 1465 | let formatter = DateFormatter() |
| 1466 | 1466 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/61b66.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -271,7 +271,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 271 | 271 | let decoder = JSONDecoder() |
| 272 | 272 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 273 | 273 | let container = try decoder.singleValueContainer() |
| 274 | - let dateStr = try container.decode(String.self) | |
| 274 | + let dateStr = try container.decode(String.self).uppercased() | |
| 275 | 275 | |
| 276 | 276 | let formatter = DateFormatter() |
| 277 | 277 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/6260a.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/65dec.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -385,7 +385,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 385 | 385 | let decoder = JSONDecoder() |
| 386 | 386 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 387 | 387 | let container = try decoder.singleValueContainer() |
| 388 | - let dateStr = try container.decode(String.self) | |
| 388 | + let dateStr = try container.decode(String.self).uppercased() | |
| 389 | 389 | |
| 390 | 390 | let formatter = DateFormatter() |
| 391 | 391 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/66121.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -282,7 +282,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 282 | 282 | let decoder = JSONDecoder() |
| 283 | 283 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 284 | 284 | let container = try decoder.singleValueContainer() |
| 285 | - let dateStr = try container.decode(String.self) | |
| 285 | + let dateStr = try container.decode(String.self).uppercased() | |
| 286 | 286 | |
| 287 | 287 | let formatter = DateFormatter() |
| 288 | 288 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/6617c.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -111,7 +111,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 111 | 111 | let decoder = JSONDecoder() |
| 112 | 112 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 113 | 113 | let container = try decoder.singleValueContainer() |
| 114 | - let dateStr = try container.decode(String.self) | |
| 114 | + let dateStr = try container.decode(String.self).uppercased() | |
| 115 | 115 | |
| 116 | 116 | let formatter = DateFormatter() |
| 117 | 117 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/67c03.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -111,7 +111,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 111 | 111 | let decoder = JSONDecoder() |
| 112 | 112 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 113 | 113 | let container = try decoder.singleValueContainer() |
| 114 | - let dateStr = try container.decode(String.self) | |
| 114 | + let dateStr = try container.decode(String.self).uppercased() | |
| 115 | 115 | |
| 116 | 116 | let formatter = DateFormatter() |
| 117 | 117 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/68c30.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -263,7 +263,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 263 | 263 | let decoder = JSONDecoder() |
| 264 | 264 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 265 | 265 | let container = try decoder.singleValueContainer() |
| 266 | - let dateStr = try container.decode(String.self) | |
| 266 | + let dateStr = try container.decode(String.self).uppercased() | |
| 267 | 267 | |
| 268 | 268 | let formatter = DateFormatter() |
| 269 | 269 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/6c155.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -435,7 +435,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 435 | 435 | let decoder = JSONDecoder() |
| 436 | 436 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 437 | 437 | let container = try decoder.singleValueContainer() |
| 438 | - let dateStr = try container.decode(String.self) | |
| 438 | + let dateStr = try container.decode(String.self).uppercased() | |
| 439 | 439 | |
| 440 | 440 | let formatter = DateFormatter() |
| 441 | 441 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/6de06.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -925,7 +925,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 925 | 925 | let decoder = JSONDecoder() |
| 926 | 926 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 927 | 927 | let container = try decoder.singleValueContainer() |
| 928 | - let dateStr = try container.decode(String.self) | |
| 928 | + let dateStr = try container.decode(String.self).uppercased() | |
| 929 | 929 | |
| 930 | 930 | let formatter = DateFormatter() |
| 931 | 931 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/6dec6.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -716,7 +716,7 @@ namespace quicktype { | ||
| 716 | 716 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 717 | 717 | if (j.find("count") != j.end() && !j.at("count").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 718 | 718 | x.set_count(j.at("count").get<int64_t>()); |
| 719 | - if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 719 | + if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 720 | 720 | x.set_created(j.at("created").get<std::string>()); |
| 721 | 721 | x.set_lang(j.at("lang").get<std::string>()); |
| 722 | 722 | x.set_results(j.at("results").get<Results>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -246,7 +246,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 246 | 246 | if (self = [super init]) { |
| 247 | 247 | if (![dict[@"count"] isKindOfClass:NSNumber.class]) return nil; |
| 248 | 248 | if ([dict[@"count"] doubleValue] != [dict[@"count"] longLongValue]) return nil; |
| 249 | - if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 249 | + if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 250 | + if (dict[@"created"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created"] substringToIndex:10]]) return nil; | |
| 250 | 251 | if (![dict[@"created"] isKindOfClass:NSString.class]) return nil; |
| 251 | 252 | if (![dict[@"lang"] isKindOfClass:NSString.class]) return nil; |
| 252 | 253 | if (![dict[@"results"] isKindOfClass:NSDictionary.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -178,6 +178,10 @@ class Query { | ||
| 178 | 178 | */ |
| 179 | 179 | public static function fromCreated(string $value): DateTime { |
| 180 | 180 | $tmp = new DateTime($value); |
| 181 | + $errors = DateTime::getLastErrors(); | |
| 182 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 183 | + throw new Exception('Invalid date-time'); | |
| 184 | + } | |
| 181 | 185 | if (!is_a($tmp, 'DateTime')) { |
| 182 | 186 | throw new Exception('Attribute Error:Query::'); |
| 183 | 187 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -817,7 +817,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 817 | 817 | let decoder = JSONDecoder() |
| 818 | 818 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 819 | 819 | let container = try decoder.singleValueContainer() |
| 820 | - let dateStr = try container.decode(String.self) | |
| 820 | + let dateStr = try container.decode(String.self).uppercased() | |
| 821 | 821 | |
| 822 | 822 | let formatter = DateFormatter() |
| 823 | 823 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/6eb00.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -90,7 +90,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 90 | 90 | let decoder = JSONDecoder() |
| 91 | 91 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 92 | 92 | let container = try decoder.singleValueContainer() |
| 93 | - let dateStr = try container.decode(String.self) | |
| 93 | + let dateStr = try container.decode(String.self).uppercased() | |
| 94 | 94 | |
| 95 | 95 | let formatter = DateFormatter() |
| 96 | 96 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/70c77.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +29 −9test/inputs/json/misc/734ad.json
Mcplusplusdefault / quicktype.hpp+4 −4
| @@ -478,7 +478,7 @@ namespace quicktype { | ||
| 478 | 478 | x.set_code_of_conduct(j.at("code_of_conduct").get<std::string>()); |
| 479 | 479 | if (j.find("contact_country") != j.end() && !j.at("contact_country").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 480 | 480 | x.set_contact_country(j.at("contact_country").get<int64_t>()); |
| 481 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 481 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 482 | 482 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 483 | 483 | x.set_entity(j.at("entity").get<std::string>()); |
| 484 | 484 | x.set_goals(j.at("goals").get<std::string>()); |
| @@ -498,7 +498,7 @@ namespace quicktype { | ||
| 498 | 498 | x.set_id(j.at("id").get<std::string>()); |
| 499 | 499 | x.set_identification_code(j.at("identification_code").get<std::string>()); |
| 500 | 500 | x.set_info_members(j.at("info_members").get<std::string>()); |
| 501 | - if (j.find("last_update_date") != j.end() && !std::regex_match(j.at("last_update_date").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 501 | + if (j.find("last_update_date") != j.end() && !std::regex_match(j.at("last_update_date").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 502 | 502 | x.set_last_update_date(j.at("last_update_date").get<std::string>()); |
| 503 | 503 | x.set_legal(j.at("legal").get<std::string>()); |
| 504 | 504 | x.set_legal_status(j.at("legal_status").get<std::string>()); |
| @@ -524,14 +524,14 @@ namespace quicktype { | ||
| 524 | 524 | x.set_number_of_natural_persons(get_stack_optional<int64_t>(j, "number_of_natural_persons")); |
| 525 | 525 | j.at("other_code_of_conduct"); |
| 526 | 526 | x.set_other_code_of_conduct(get_stack_optional<std::string>(j, "other_code_of_conduct")); |
| 527 | - if (j.find("registration_date") != j.end() && !std::regex_match(j.at("registration_date").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 527 | + if (j.find("registration_date") != j.end() && !std::regex_match(j.at("registration_date").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 528 | 528 | x.set_registration_date(j.at("registration_date").get<std::string>()); |
| 529 | 529 | x.set_status(j.at("status").get<Status>()); |
| 530 | 530 | x.set_structure_members(j.at("structure_members").get<std::string>()); |
| 531 | 531 | if (j.find("sub_category") != j.end() && !j.at("sub_category").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 532 | 532 | x.set_sub_category(j.at("sub_category").get<int64_t>()); |
| 533 | 533 | x.set_sub_category_title(j.at("sub_category_title").get<std::string>()); |
| 534 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 534 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 535 | 535 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 536 | 536 | x.set_uri(j.at("uri").get<std::string>()); |
| 537 | 537 | j.at("web_site_url"); |
Mobjective-cdefault / QTTopLevel.m+8 −4
| @@ -318,7 +318,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 318 | 318 | if (![dict[@"code_of_conduct"] isKindOfClass:NSString.class]) return nil; |
| 319 | 319 | if (![dict[@"contact_country"] isKindOfClass:NSNumber.class]) return nil; |
| 320 | 320 | if ([dict[@"contact_country"] doubleValue] != [dict[@"contact_country"] longLongValue]) return nil; |
| 321 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 321 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 322 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 322 | 323 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 323 | 324 | if (![dict[@"entity"] isKindOfClass:NSString.class]) return nil; |
| 324 | 325 | if (![dict[@"goals"] isKindOfClass:NSString.class]) return nil; |
| @@ -334,7 +335,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 334 | 335 | if (![dict[@"identification_code"] isKindOfClass:NSString.class]) return nil; |
| 335 | 336 | if (![dict[@"id"] isKindOfClass:NSString.class]) return nil; |
| 336 | 337 | if (![dict[@"info_members"] isKindOfClass:NSString.class]) return nil; |
| 337 | - if (dict[@"last_update_date"] && [dict[@"last_update_date"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 338 | + if (dict[@"last_update_date"] && [dict[@"last_update_date"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 339 | + if (dict[@"last_update_date"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"last_update_date"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"last_update_date"] substringToIndex:10]]) return nil; | |
| 338 | 340 | if (![dict[@"last_update_date"] isKindOfClass:NSString.class]) return nil; |
| 339 | 341 | if (![dict[@"legal"] isKindOfClass:NSString.class]) return nil; |
| 340 | 342 | if (![dict[@"legal_status"] isKindOfClass:NSString.class]) return nil; |
| @@ -353,14 +355,16 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 353 | 355 | if (!dict[@"networking"]) return nil; |
| 354 | 356 | if (!dict[@"number_of_natural_persons"]) return nil; |
| 355 | 357 | if (!dict[@"other_code_of_conduct"]) return nil; |
| 356 | - if (dict[@"registration_date"] && [dict[@"registration_date"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 358 | + if (dict[@"registration_date"] && [dict[@"registration_date"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 359 | + if (dict[@"registration_date"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"registration_date"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"registration_date"] substringToIndex:10]]) return nil; | |
| 357 | 360 | if (![dict[@"registration_date"] isKindOfClass:NSString.class]) return nil; |
| 358 | 361 | if (![dict[@"status"] isKindOfClass:NSString.class]) return nil; |
| 359 | 362 | if (![dict[@"structure_members"] isKindOfClass:NSString.class]) return nil; |
| 360 | 363 | if (![dict[@"sub_category"] isKindOfClass:NSNumber.class]) return nil; |
| 361 | 364 | if ([dict[@"sub_category"] doubleValue] != [dict[@"sub_category"] longLongValue]) return nil; |
| 362 | 365 | if (![dict[@"sub_category_title"] isKindOfClass:NSString.class]) return nil; |
| 363 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 366 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 367 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 364 | 368 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 365 | 369 | if (![dict[@"uri"] isKindOfClass:NSString.class]) return nil; |
| 366 | 370 | if (!dict[@"web_site_url"]) return nil; |
Mphpdefault / TopLevel.php+16 −0
| @@ -1685,6 +1685,10 @@ class Result { | ||
| 1685 | 1685 | */ |
| 1686 | 1686 | public static function fromCreatedAt(string $value): DateTime { |
| 1687 | 1687 | $tmp = new DateTime($value); |
| 1688 | + $errors = DateTime::getLastErrors(); | |
| 1689 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 1690 | + throw new Exception('Invalid date-time'); | |
| 1691 | + } | |
| 1688 | 1692 | if (!is_a($tmp, 'DateTime')) { |
| 1689 | 1693 | throw new Exception('Attribute Error:Result::'); |
| 1690 | 1694 | } |
| @@ -2437,6 +2441,10 @@ class Result { | ||
| 2437 | 2441 | */ |
| 2438 | 2442 | public static function fromLastUpdateDate(string $value): DateTime { |
| 2439 | 2443 | $tmp = new DateTime($value); |
| 2444 | + $errors = DateTime::getLastErrors(); | |
| 2445 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 2446 | + throw new Exception('Invalid date-time'); | |
| 2447 | + } | |
| 2440 | 2448 | if (!is_a($tmp, 'DateTime')) { |
| 2441 | 2449 | throw new Exception('Attribute Error:Result::'); |
| 2442 | 2450 | } |
| @@ -3269,6 +3277,10 @@ class Result { | ||
| 3269 | 3277 | */ |
| 3270 | 3278 | public static function fromRegistrationDate(string $value): DateTime { |
| 3271 | 3279 | $tmp = new DateTime($value); |
| 3280 | + $errors = DateTime::getLastErrors(); | |
| 3281 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 3282 | + throw new Exception('Invalid date-time'); | |
| 3283 | + } | |
| 3272 | 3284 | if (!is_a($tmp, 'DateTime')) { |
| 3273 | 3285 | throw new Exception('Attribute Error:Result::'); |
| 3274 | 3286 | } |
| @@ -3512,6 +3524,10 @@ class Result { | ||
| 3512 | 3524 | */ |
| 3513 | 3525 | public static function fromUpdatedAt(string $value): DateTime { |
| 3514 | 3526 | $tmp = new DateTime($value); |
| 3527 | + $errors = DateTime::getLastErrors(); | |
| 3528 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 3529 | + throw new Exception('Invalid date-time'); | |
| 3530 | + } | |
| 3515 | 3531 | if (!is_a($tmp, 'DateTime')) { |
| 3516 | 3532 | throw new Exception('Attribute Error:Result::'); |
| 3517 | 3533 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -399,7 +399,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 399 | 399 | let decoder = JSONDecoder() |
| 400 | 400 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 401 | 401 | let container = try decoder.singleValueContainer() |
| 402 | - let dateStr = try container.decode(String.self) | |
| 402 | + let dateStr = try container.decode(String.self).uppercased() | |
| 403 | 403 | |
| 404 | 404 | let formatter = DateFormatter() |
| 405 | 405 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/75912.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/7681c.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -732,7 +732,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 732 | 732 | let decoder = JSONDecoder() |
| 733 | 733 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 734 | 734 | let container = try decoder.singleValueContainer() |
| 735 | - let dateStr = try container.decode(String.self) | |
| 735 | + let dateStr = try container.decode(String.self).uppercased() | |
| 736 | 736 | |
| 737 | 737 | let formatter = DateFormatter() |
| 738 | 738 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/76ae1.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -1439,7 +1439,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 1439 | 1439 | let decoder = JSONDecoder() |
| 1440 | 1440 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 1441 | 1441 | let container = try decoder.singleValueContainer() |
| 1442 | - let dateStr = try container.decode(String.self) | |
| 1442 | + let dateStr = try container.decode(String.self).uppercased() | |
| 1443 | 1443 | |
| 1444 | 1444 | let formatter = DateFormatter() |
| 1445 | 1445 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/77392.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -167,7 +167,7 @@ namespace quicktype { | ||
| 167 | 167 | inline void from_json(const json & j, TopLevelElement& x) { |
| 168 | 168 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 169 | 169 | x.set_designation(j.at("designation").get<std::string>()); |
| 170 | - if (j.find("discovery_date") != j.end() && !std::regex_match(j.at("discovery_date").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 170 | + if (j.find("discovery_date") != j.end() && !std::regex_match(j.at("discovery_date").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 171 | 171 | x.set_discovery_date(j.at("discovery_date").get<std::string>()); |
| 172 | 172 | if (j.find("h_mag") != j.end() && j.at("h_mag").is_null()) throw std::runtime_error("Unexpected null"); |
| 173 | 173 | x.set_h_mag(get_stack_optional<std::string>(j, "h_mag")); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -159,7 +159,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 159 | 159 | { |
| 160 | 160 | if (self = [super init]) { |
| 161 | 161 | if (![dict[@"designation"] isKindOfClass:NSString.class]) return nil; |
| 162 | - if (dict[@"discovery_date"] && [dict[@"discovery_date"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 162 | + if (dict[@"discovery_date"] && [dict[@"discovery_date"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 163 | + if (dict[@"discovery_date"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"discovery_date"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"discovery_date"] substringToIndex:10]]) return nil; | |
| 163 | 164 | if (![dict[@"discovery_date"] isKindOfClass:NSString.class]) return nil; |
| 164 | 165 | if (![dict[@"i_deg"] isKindOfClass:NSString.class]) return nil; |
| 165 | 166 | if (![dict[@"moid_au"] isKindOfClass:NSString.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -94,6 +94,10 @@ class TopLevel { | ||
| 94 | 94 | */ |
| 95 | 95 | public static function fromDiscoveryDate(string $value): DateTime { |
| 96 | 96 | $tmp = new DateTime($value); |
| 97 | + $errors = DateTime::getLastErrors(); | |
| 98 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 99 | + throw new Exception('Invalid date-time'); | |
| 100 | + } | |
| 97 | 101 | if (!is_a($tmp, 'DateTime')) { |
| 98 | 102 | throw new Exception('Attribute Error:TopLevel::'); |
| 99 | 103 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -136,7 +136,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 136 | 136 | let decoder = JSONDecoder() |
| 137 | 137 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 138 | 138 | let container = try decoder.singleValueContainer() |
| 139 | - let dateStr = try container.decode(String.self) | |
| 139 | + let dateStr = try container.decode(String.self).uppercased() | |
| 140 | 140 | |
| 141 | 141 | let formatter = DateFormatter() |
| 142 | 142 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/7d397.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -675,7 +675,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 675 | 675 | let decoder = JSONDecoder() |
| 676 | 676 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 677 | 677 | let container = try decoder.singleValueContainer() |
| 678 | - let dateStr = try container.decode(String.self) | |
| 678 | + let dateStr = try container.decode(String.self).uppercased() | |
| 679 | 679 | |
| 680 | 680 | let formatter = DateFormatter() |
| 681 | 681 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/7d722.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -271,7 +271,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 271 | 271 | let decoder = JSONDecoder() |
| 272 | 272 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 273 | 273 | let container = try decoder.singleValueContainer() |
| 274 | - let dateStr = try container.decode(String.self) | |
| 274 | + let dateStr = try container.decode(String.self).uppercased() | |
| 275 | 275 | |
| 276 | 276 | let formatter = DateFormatter() |
| 277 | 277 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/7df41.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -123,7 +123,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 123 | 123 | let decoder = JSONDecoder() |
| 124 | 124 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 125 | 125 | let container = try decoder.singleValueContainer() |
| 126 | - let dateStr = try container.decode(String.self) | |
| 126 | + let dateStr = try container.decode(String.self).uppercased() | |
| 127 | 127 | |
| 128 | 128 | let formatter = DateFormatter() |
| 129 | 129 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/7dfa6.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/7eb30.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -241,7 +241,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 241 | 241 | let decoder = JSONDecoder() |
| 242 | 242 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 243 | 243 | let container = try decoder.singleValueContainer() |
| 244 | - let dateStr = try container.decode(String.self) | |
| 244 | + let dateStr = try container.decode(String.self).uppercased() | |
| 245 | 245 | |
| 246 | 246 | let formatter = DateFormatter() |
| 247 | 247 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +15 −5test/inputs/json/misc/7f568.json
Mcplusplusdefault / quicktype.hpp+2 −2
| @@ -254,7 +254,7 @@ namespace quicktype { | ||
| 254 | 254 | x.set_comments(j.at("comments").get<int64_t>()); |
| 255 | 255 | x.set_comments_url(j.at("comments_url").get<std::string>()); |
| 256 | 256 | x.set_commits_url(j.at("commits_url").get<std::string>()); |
| 257 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 257 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 258 | 258 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 259 | 259 | j.at("description"); |
| 260 | 260 | x.set_description(get_stack_optional<std::string>(j, "description")); |
| @@ -266,7 +266,7 @@ namespace quicktype { | ||
| 266 | 266 | x.set_id(j.at("id").get<std::string>()); |
| 267 | 267 | x.set_top_level_public(j.at("public").get<bool>()); |
| 268 | 268 | x.set_truncated(j.at("truncated").get<bool>()); |
| 269 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 269 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 270 | 270 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 271 | 271 | x.set_url(j.at("url").get<std::string>()); |
| 272 | 272 | x.set_user(get_untyped(j, "user")); |
Mobjective-cdefault / QTTopLevel.m+4 −2
| @@ -153,7 +153,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 153 | 153 | if ([dict[@"comments"] doubleValue] != [dict[@"comments"] longLongValue]) return nil; |
| 154 | 154 | if (![dict[@"comments_url"] isKindOfClass:NSString.class]) return nil; |
| 155 | 155 | if (![dict[@"commits_url"] isKindOfClass:NSString.class]) return nil; |
| 156 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 156 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 157 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 157 | 158 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 158 | 159 | if (![dict[@"files"] isKindOfClass:NSDictionary.class]) return nil; |
| 159 | 160 | if (![dict[@"forks_url"] isKindOfClass:NSString.class]) return nil; |
| @@ -164,7 +165,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 164 | 165 | if (![dict[@"public"] isKindOfClass:NSNumber.class]) return nil; |
| 165 | 166 | if (![dict[@"truncated"] isKindOfClass:NSNumber.class]) return nil; |
| 166 | 167 | if (!dict[@"description"]) return nil; |
| 167 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 168 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 169 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 168 | 170 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 169 | 171 | if (![dict[@"url"] isKindOfClass:NSString.class]) return nil; |
| 170 | 172 | if (!dict[@"user"]) return nil; |
Mphpdefault / TopLevel.php+8 −0
| @@ -206,6 +206,10 @@ class TopLevel { | ||
| 206 | 206 | */ |
| 207 | 207 | public static function fromCreatedAt(string $value): DateTime { |
| 208 | 208 | $tmp = new DateTime($value); |
| 209 | + $errors = DateTime::getLastErrors(); | |
| 210 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 211 | + throw new Exception('Invalid date-time'); | |
| 212 | + } | |
| 209 | 213 | if (!is_a($tmp, 'DateTime')) { |
| 210 | 214 | throw new Exception('Attribute Error:TopLevel::'); |
| 211 | 215 | } |
| @@ -708,6 +712,10 @@ class TopLevel { | ||
| 708 | 712 | */ |
| 709 | 713 | public static function fromUpdatedAt(string $value): DateTime { |
| 710 | 714 | $tmp = new DateTime($value); |
| 715 | + $errors = DateTime::getLastErrors(); | |
| 716 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 717 | + throw new Exception('Invalid date-time'); | |
| 718 | + } | |
| 711 | 719 | if (!is_a($tmp, 'DateTime')) { |
| 712 | 720 | throw new Exception('Attribute Error:TopLevel::'); |
| 713 | 721 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -210,7 +210,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 210 | 210 | let decoder = JSONDecoder() |
| 211 | 211 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 212 | 212 | let container = try decoder.singleValueContainer() |
| 213 | - let dateStr = try container.decode(String.self) | |
| 213 | + let dateStr = try container.decode(String.self).uppercased() | |
| 214 | 214 | |
| 215 | 215 | let formatter = DateFormatter() |
| 216 | 216 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/7fbfb.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -240,7 +240,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 240 | 240 | let decoder = JSONDecoder() |
| 241 | 241 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 242 | 242 | let container = try decoder.singleValueContainer() |
| 243 | - let dateStr = try container.decode(String.self) | |
| 243 | + let dateStr = try container.decode(String.self).uppercased() | |
| 244 | 244 | |
| 245 | 245 | let formatter = DateFormatter() |
| 246 | 246 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +15 −5test/inputs/json/misc/80aff.json
Mcplusplusdefault / quicktype.hpp+2 −2
| @@ -208,7 +208,7 @@ namespace quicktype { | ||
| 208 | 208 | |
| 209 | 209 | inline void from_json(const json & j, Result& x) { |
| 210 | 210 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 211 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 211 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 212 | 212 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 213 | 213 | if (j.find("id") != j.end() && !j.at("id").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 214 | 214 | x.set_id(j.at("id").get<int64_t>()); |
| @@ -217,7 +217,7 @@ namespace quicktype { | ||
| 217 | 217 | x.set_name(j.at("name").get<std::string>()); |
| 218 | 218 | j.at("parent"); |
| 219 | 219 | x.set_parent(get_stack_optional<int64_t>(j, "parent")); |
| 220 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 220 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 221 | 221 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 222 | 222 | x.set_uri(j.at("uri").get<std::string>()); |
| 223 | 223 | } |
Mobjective-cdefault / QTTopLevel.m+4 −2
| @@ -229,7 +229,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 229 | 229 | - (instancetype)initWithJSONDictionary:(NSDictionary *)dict |
| 230 | 230 | { |
| 231 | 231 | if (self = [super init]) { |
| 232 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 232 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 233 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 233 | 234 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 234 | 235 | if (![dict[@"id"] isKindOfClass:NSNumber.class]) return nil; |
| 235 | 236 | if ([dict[@"id"] doubleValue] != [dict[@"id"] longLongValue]) return nil; |
| @@ -237,7 +238,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 237 | 238 | if ([dict[@"items"] doubleValue] != [dict[@"items"] longLongValue]) return nil; |
| 238 | 239 | if (![dict[@"name"] isKindOfClass:NSString.class]) return nil; |
| 239 | 240 | if (!dict[@"parent"]) return nil; |
| 240 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 241 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 242 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 241 | 243 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 242 | 244 | if (![dict[@"uri"] isKindOfClass:NSString.class]) return nil; |
| 243 | 245 | [self setValuesForKeysWithDictionary:dict]; |
Mphpdefault / TopLevel.php+8 −0
| @@ -539,6 +539,10 @@ class Result { | ||
| 539 | 539 | */ |
| 540 | 540 | public static function fromCreatedAt(string $value): DateTime { |
| 541 | 541 | $tmp = new DateTime($value); |
| 542 | + $errors = DateTime::getLastErrors(); | |
| 543 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 544 | + throw new Exception('Invalid date-time'); | |
| 545 | + } | |
| 542 | 546 | if (!is_a($tmp, 'DateTime')) { |
| 543 | 547 | throw new Exception('Attribute Error:Result::'); |
| 544 | 548 | } |
| @@ -791,6 +795,10 @@ class Result { | ||
| 791 | 795 | */ |
| 792 | 796 | public static function fromUpdatedAt(string $value): DateTime { |
| 793 | 797 | $tmp = new DateTime($value); |
| 798 | + $errors = DateTime::getLastErrors(); | |
| 799 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 800 | + throw new Exception('Invalid date-time'); | |
| 801 | + } | |
| 794 | 802 | if (!is_a($tmp, 'DateTime')) { |
| 795 | 803 | throw new Exception('Attribute Error:Result::'); |
| 796 | 804 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -190,7 +190,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 190 | 190 | let decoder = JSONDecoder() |
| 191 | 191 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 192 | 192 | let container = try decoder.singleValueContainer() |
| 193 | - let dateStr = try container.decode(String.self) | |
| 193 | + let dateStr = try container.decode(String.self).uppercased() | |
| 194 | 194 | |
| 195 | 195 | let formatter = DateFormatter() |
| 196 | 196 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/82509.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/8592b.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -687,7 +687,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 687 | 687 | let decoder = JSONDecoder() |
| 688 | 688 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 689 | 689 | let container = try decoder.singleValueContainer() |
| 690 | - let dateStr = try container.decode(String.self) | |
| 690 | + let dateStr = try container.decode(String.self).uppercased() | |
| 691 | 691 | |
| 692 | 692 | let formatter = DateFormatter() |
| 693 | 693 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/88130.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -711,7 +711,7 @@ namespace quicktype { | ||
| 711 | 711 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 712 | 712 | if (j.find("count") != j.end() && !j.at("count").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 713 | 713 | x.set_count(j.at("count").get<int64_t>()); |
| 714 | - if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 714 | + if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 715 | 715 | x.set_created(j.at("created").get<std::string>()); |
| 716 | 716 | x.set_lang(j.at("lang").get<std::string>()); |
| 717 | 717 | x.set_results(j.at("results").get<Results>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -217,7 +217,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 217 | 217 | if (self = [super init]) { |
| 218 | 218 | if (![dict[@"count"] isKindOfClass:NSNumber.class]) return nil; |
| 219 | 219 | if ([dict[@"count"] doubleValue] != [dict[@"count"] longLongValue]) return nil; |
| 220 | - if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 220 | + if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 221 | + if (dict[@"created"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created"] substringToIndex:10]]) return nil; | |
| 221 | 222 | if (![dict[@"created"] isKindOfClass:NSString.class]) return nil; |
| 222 | 223 | if (![dict[@"lang"] isKindOfClass:NSString.class]) return nil; |
| 223 | 224 | if (![dict[@"results"] isKindOfClass:NSDictionary.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -178,6 +178,10 @@ class Query { | ||
| 178 | 178 | */ |
| 179 | 179 | public static function fromCreated(string $value): DateTime { |
| 180 | 180 | $tmp = new DateTime($value); |
| 181 | + $errors = DateTime::getLastErrors(); | |
| 182 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 183 | + throw new Exception('Invalid date-time'); | |
| 184 | + } | |
| 181 | 185 | if (!is_a($tmp, 'DateTime')) { |
| 182 | 186 | throw new Exception('Attribute Error:Query::'); |
| 183 | 187 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -811,7 +811,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 811 | 811 | let decoder = JSONDecoder() |
| 812 | 812 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 813 | 813 | let container = try decoder.singleValueContainer() |
| 814 | - let dateStr = try container.decode(String.self) | |
| 814 | + let dateStr = try container.decode(String.self).uppercased() | |
| 815 | 815 | |
| 816 | 816 | let formatter = DateFormatter() |
| 817 | 817 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/8a62c.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/908db.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -147,7 +147,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 147 | 147 | let decoder = JSONDecoder() |
| 148 | 148 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 149 | 149 | let container = try decoder.singleValueContainer() |
| 150 | - let dateStr = try container.decode(String.self) | |
| 150 | + let dateStr = try container.decode(String.self).uppercased() | |
| 151 | 151 | |
| 152 | 152 | let formatter = DateFormatter() |
| 153 | 153 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/9617f.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/96f7c.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -75,7 +75,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 75 | 75 | let decoder = JSONDecoder() |
| 76 | 76 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 77 | 77 | let container = try decoder.singleValueContainer() |
| 78 | - let dateStr = try container.decode(String.self) | |
| 78 | + let dateStr = try container.decode(String.self).uppercased() | |
| 79 | 79 | |
| 80 | 80 | let formatter = DateFormatter() |
| 81 | 81 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/9847b.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -86,7 +86,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 86 | 86 | let decoder = JSONDecoder() |
| 87 | 87 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 88 | 88 | let container = try decoder.singleValueContainer() |
| 89 | - let dateStr = try container.decode(String.self) | |
| 89 | + let dateStr = try container.decode(String.self).uppercased() | |
| 90 | 90 | |
| 91 | 91 | let formatter = DateFormatter() |
| 92 | 92 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/9929c.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -711,7 +711,7 @@ namespace quicktype { | ||
| 711 | 711 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 712 | 712 | if (j.find("count") != j.end() && !j.at("count").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 713 | 713 | x.set_count(j.at("count").get<int64_t>()); |
| 714 | - if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 714 | + if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 715 | 715 | x.set_created(j.at("created").get<std::string>()); |
| 716 | 716 | x.set_lang(j.at("lang").get<std::string>()); |
| 717 | 717 | x.set_results(j.at("results").get<Results>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -217,7 +217,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 217 | 217 | if (self = [super init]) { |
| 218 | 218 | if (![dict[@"count"] isKindOfClass:NSNumber.class]) return nil; |
| 219 | 219 | if ([dict[@"count"] doubleValue] != [dict[@"count"] longLongValue]) return nil; |
| 220 | - if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 220 | + if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 221 | + if (dict[@"created"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created"] substringToIndex:10]]) return nil; | |
| 221 | 222 | if (![dict[@"created"] isKindOfClass:NSString.class]) return nil; |
| 222 | 223 | if (![dict[@"lang"] isKindOfClass:NSString.class]) return nil; |
| 223 | 224 | if (![dict[@"results"] isKindOfClass:NSDictionary.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -178,6 +178,10 @@ class Query { | ||
| 178 | 178 | */ |
| 179 | 179 | public static function fromCreated(string $value): DateTime { |
| 180 | 180 | $tmp = new DateTime($value); |
| 181 | + $errors = DateTime::getLastErrors(); | |
| 182 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 183 | + throw new Exception('Invalid date-time'); | |
| 184 | + } | |
| 181 | 185 | if (!is_a($tmp, 'DateTime')) { |
| 182 | 186 | throw new Exception('Attribute Error:Query::'); |
| 183 | 187 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -811,7 +811,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 811 | 811 | let decoder = JSONDecoder() |
| 812 | 812 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 813 | 813 | let container = try decoder.singleValueContainer() |
| 814 | - let dateStr = try container.decode(String.self) | |
| 814 | + let dateStr = try container.decode(String.self).uppercased() | |
| 815 | 815 | |
| 816 | 816 | let formatter = DateFormatter() |
| 817 | 817 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/996bd.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -281,7 +281,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 281 | 281 | let decoder = JSONDecoder() |
| 282 | 282 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 283 | 283 | let container = try decoder.singleValueContainer() |
| 284 | - let dateStr = try container.decode(String.self) | |
| 284 | + let dateStr = try container.decode(String.self).uppercased() | |
| 285 | 285 | |
| 286 | 286 | let formatter = DateFormatter() |
| 287 | 287 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/9a503.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -264,7 +264,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 264 | 264 | let decoder = JSONDecoder() |
| 265 | 265 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 266 | 266 | let container = try decoder.singleValueContainer() |
| 267 | - let dateStr = try container.decode(String.self) | |
| 267 | + let dateStr = try container.decode(String.self).uppercased() | |
| 268 | 268 | |
| 269 | 269 | let formatter = DateFormatter() |
| 270 | 270 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +15 −5test/inputs/json/misc/9ac3b.json
Mcplusplusdefault / quicktype.hpp+2 −2
| @@ -237,7 +237,7 @@ namespace quicktype { | ||
| 237 | 237 | |
| 238 | 238 | inline void from_json(const json & j, Result& x) { |
| 239 | 239 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 240 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 240 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 241 | 241 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 242 | 242 | x.set_entity(j.at("entity").get<std::string>()); |
| 243 | 243 | x.set_first_name(j.at("first_name").get<std::string>()); |
| @@ -249,7 +249,7 @@ namespace quicktype { | ||
| 249 | 249 | x.set_status(j.at("status").get<Status>()); |
| 250 | 250 | j.at("title"); |
| 251 | 251 | x.set_title(get_stack_optional<Title>(j, "title")); |
| 252 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 252 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 253 | 253 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 254 | 254 | x.set_uri(j.at("uri").get<std::string>()); |
| 255 | 255 | } |
Mobjective-cdefault / QTTopLevel.m+4 −2
| @@ -286,7 +286,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 286 | 286 | - (instancetype)initWithJSONDictionary:(NSDictionary *)dict |
| 287 | 287 | { |
| 288 | 288 | if (self = [super init]) { |
| 289 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 289 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 290 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 290 | 291 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 291 | 292 | if (![dict[@"entity"] isKindOfClass:NSString.class]) return nil; |
| 292 | 293 | if (![dict[@"first_name"] isKindOfClass:NSString.class]) return nil; |
| @@ -296,7 +297,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 296 | 297 | if (!dict[@"position"]) return nil; |
| 297 | 298 | if (![dict[@"status"] isKindOfClass:NSString.class]) return nil; |
| 298 | 299 | if (!dict[@"title"]) return nil; |
| 299 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 300 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 301 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 300 | 302 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 301 | 303 | if (![dict[@"uri"] isKindOfClass:NSString.class]) return nil; |
| 302 | 304 | [self setValuesForKeysWithDictionary:dict]; |
Mphpdefault / TopLevel.php+8 −0
| @@ -551,6 +551,10 @@ class Result { | ||
| 551 | 551 | */ |
| 552 | 552 | public static function fromCreatedAt(string $value): DateTime { |
| 553 | 553 | $tmp = new DateTime($value); |
| 554 | + $errors = DateTime::getLastErrors(); | |
| 555 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 556 | + throw new Exception('Invalid date-time'); | |
| 557 | + } | |
| 554 | 558 | if (!is_a($tmp, 'DateTime')) { |
| 555 | 559 | throw new Exception('Attribute Error:Result::'); |
| 556 | 560 | } |
| @@ -1003,6 +1007,10 @@ class Result { | ||
| 1003 | 1007 | */ |
| 1004 | 1008 | public static function fromUpdatedAt(string $value): DateTime { |
| 1005 | 1009 | $tmp = new DateTime($value); |
| 1010 | + $errors = DateTime::getLastErrors(); | |
| 1011 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 1012 | + throw new Exception('Invalid date-time'); | |
| 1013 | + } | |
| 1006 | 1014 | if (!is_a($tmp, 'DateTime')) { |
| 1007 | 1015 | throw new Exception('Attribute Error:Result::'); |
| 1008 | 1016 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -216,7 +216,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 216 | 216 | let decoder = JSONDecoder() |
| 217 | 217 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 218 | 218 | let container = try decoder.singleValueContainer() |
| 219 | - let dateStr = try container.decode(String.self) | |
| 219 | + let dateStr = try container.decode(String.self).uppercased() | |
| 220 | 220 | |
| 221 | 221 | let formatter = DateFormatter() |
| 222 | 222 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/9eed5.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -263,7 +263,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 263 | 263 | let decoder = JSONDecoder() |
| 264 | 264 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 265 | 265 | let container = try decoder.singleValueContainer() |
| 266 | - let dateStr = try container.decode(String.self) | |
| 266 | + let dateStr = try container.decode(String.self).uppercased() | |
| 267 | 267 | |
| 268 | 268 | let formatter = DateFormatter() |
| 269 | 269 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/a0496.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -239,7 +239,7 @@ namespace quicktype { | ||
| 239 | 239 | x.set_source_name(j.at("source_name").get<std::string>()); |
| 240 | 240 | x.set_to_date(j.at("to_date").get<std::string>()); |
| 241 | 241 | x.set_type(j.at("type").get<std::string>()); |
| 242 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 242 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 243 | 243 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 244 | 244 | x.set_urlize_name(j.at("urlize_name").get<std::string>()); |
| 245 | 245 | } |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -125,7 +125,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 125 | 125 | if (![dict[@"description"] isKindOfClass:NSString.class]) return nil; |
| 126 | 126 | if (![dict[@"to_date"] isKindOfClass:NSString.class]) return nil; |
| 127 | 127 | if (![dict[@"type"] isKindOfClass:NSString.class]) return nil; |
| 128 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 128 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 129 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 129 | 130 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 130 | 131 | if (![dict[@"urlize_name"] isKindOfClass:NSString.class]) return nil; |
| 131 | 132 | [self setValuesForKeysWithDictionary:dict]; |
Mphpdefault / TopLevel.php+4 −0
| @@ -841,6 +841,10 @@ class TopLevel { | ||
| 841 | 841 | */ |
| 842 | 842 | public static function fromUpdatedAt(string $value): DateTime { |
| 843 | 843 | $tmp = new DateTime($value); |
| 844 | + $errors = DateTime::getLastErrors(); | |
| 845 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 846 | + throw new Exception('Invalid date-time'); | |
| 847 | + } | |
| 844 | 848 | if (!is_a($tmp, 'DateTime')) { |
| 845 | 849 | throw new Exception('Attribute Error:TopLevel::'); |
| 846 | 850 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -197,7 +197,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 197 | 197 | let decoder = JSONDecoder() |
| 198 | 198 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 199 | 199 | let container = try decoder.singleValueContainer() |
| 200 | - let dateStr = try container.decode(String.self) | |
| 200 | + let dateStr = try container.decode(String.self).uppercased() | |
| 201 | 201 | |
| 202 | 202 | let formatter = DateFormatter() |
| 203 | 203 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/a1eca.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -711,7 +711,7 @@ namespace quicktype { | ||
| 711 | 711 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 712 | 712 | if (j.find("count") != j.end() && !j.at("count").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 713 | 713 | x.set_count(j.at("count").get<int64_t>()); |
| 714 | - if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 714 | + if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 715 | 715 | x.set_created(j.at("created").get<std::string>()); |
| 716 | 716 | x.set_lang(j.at("lang").get<std::string>()); |
| 717 | 717 | x.set_results(j.at("results").get<Results>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -217,7 +217,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 217 | 217 | if (self = [super init]) { |
| 218 | 218 | if (![dict[@"count"] isKindOfClass:NSNumber.class]) return nil; |
| 219 | 219 | if ([dict[@"count"] doubleValue] != [dict[@"count"] longLongValue]) return nil; |
| 220 | - if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 220 | + if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 221 | + if (dict[@"created"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created"] substringToIndex:10]]) return nil; | |
| 221 | 222 | if (![dict[@"created"] isKindOfClass:NSString.class]) return nil; |
| 222 | 223 | if (![dict[@"lang"] isKindOfClass:NSString.class]) return nil; |
| 223 | 224 | if (![dict[@"results"] isKindOfClass:NSDictionary.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -178,6 +178,10 @@ class Query { | ||
| 178 | 178 | */ |
| 179 | 179 | public static function fromCreated(string $value): DateTime { |
| 180 | 180 | $tmp = new DateTime($value); |
| 181 | + $errors = DateTime::getLastErrors(); | |
| 182 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 183 | + throw new Exception('Invalid date-time'); | |
| 184 | + } | |
| 181 | 185 | if (!is_a($tmp, 'DateTime')) { |
| 182 | 186 | throw new Exception('Attribute Error:Query::'); |
| 183 | 187 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -811,7 +811,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 811 | 811 | let decoder = JSONDecoder() |
| 812 | 812 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 813 | 813 | let container = try decoder.singleValueContainer() |
| 814 | - let dateStr = try container.decode(String.self) | |
| 814 | + let dateStr = try container.decode(String.self).uppercased() | |
| 815 | 815 | |
| 816 | 816 | let formatter = DateFormatter() |
| 817 | 817 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/a3d8c.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -871,7 +871,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 871 | 871 | let decoder = JSONDecoder() |
| 872 | 872 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 873 | 873 | let container = try decoder.singleValueContainer() |
| 874 | - let dateStr = try container.decode(String.self) | |
| 874 | + let dateStr = try container.decode(String.self).uppercased() | |
| 875 | 875 | |
| 876 | 876 | let formatter = DateFormatter() |
| 877 | 877 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/a45b0.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -106,7 +106,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 106 | 106 | let decoder = JSONDecoder() |
| 107 | 107 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 108 | 108 | let container = try decoder.singleValueContainer() |
| 109 | - let dateStr = try container.decode(String.self) | |
| 109 | + let dateStr = try container.decode(String.self).uppercased() | |
| 110 | 110 | |
| 111 | 111 | let formatter = DateFormatter() |
| 112 | 112 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/a71df.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -271,7 +271,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 271 | 271 | let decoder = JSONDecoder() |
| 272 | 272 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 273 | 273 | let container = try decoder.singleValueContainer() |
| 274 | - let dateStr = try container.decode(String.self) | |
| 274 | + let dateStr = try container.decode(String.self).uppercased() | |
| 275 | 275 | |
| 276 | 276 | let formatter = DateFormatter() |
| 277 | 277 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/a9691.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/ab0d1.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -106,7 +106,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 106 | 106 | let decoder = JSONDecoder() |
| 107 | 107 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 108 | 108 | let container = try decoder.singleValueContainer() |
| 109 | - let dateStr = try container.decode(String.self) | |
| 109 | + let dateStr = try container.decode(String.self).uppercased() | |
| 110 | 110 | |
| 111 | 111 | let formatter = DateFormatter() |
| 112 | 112 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/abb4b.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/ac944.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/ad8be.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -348,7 +348,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 348 | 348 | let decoder = JSONDecoder() |
| 349 | 349 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 350 | 350 | let container = try decoder.singleValueContainer() |
| 351 | - let dateStr = try container.decode(String.self) | |
| 351 | + let dateStr = try container.decode(String.self).uppercased() | |
| 352 | 352 | |
| 353 | 353 | let formatter = DateFormatter() |
| 354 | 354 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/ae7f0.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -510,7 +510,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 510 | 510 | let decoder = JSONDecoder() |
| 511 | 511 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 512 | 512 | let container = try decoder.singleValueContainer() |
| 513 | - let dateStr = try container.decode(String.self) | |
| 513 | + let dateStr = try container.decode(String.self).uppercased() | |
| 514 | 514 | |
| 515 | 515 | let formatter = DateFormatter() |
| 516 | 516 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/ae9ca.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -268,7 +268,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 268 | 268 | let decoder = JSONDecoder() |
| 269 | 269 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 270 | 270 | let container = try decoder.singleValueContainer() |
| 271 | - let dateStr = try container.decode(String.self) | |
| 271 | + let dateStr = try container.decode(String.self).uppercased() | |
| 272 | 272 | |
| 273 | 273 | let formatter = DateFormatter() |
| 274 | 274 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/af2d1.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -511,7 +511,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 511 | 511 | let decoder = JSONDecoder() |
| 512 | 512 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 513 | 513 | let container = try decoder.singleValueContainer() |
| 514 | - let dateStr = try container.decode(String.self) | |
| 514 | + let dateStr = try container.decode(String.self).uppercased() | |
| 515 | 515 | |
| 516 | 516 | let formatter = DateFormatter() |
| 517 | 517 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
3 generated files · +6 −2test/inputs/json/misc/b4865.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -232,7 +232,7 @@ namespace quicktype { | ||
| 232 | 232 | x.set_reclat(get_stack_optional<std::string>(j, "reclat")); |
| 233 | 233 | if (j.find("reclong") != j.end() && j.at("reclong").is_null()) throw std::runtime_error("Unexpected null"); |
| 234 | 234 | x.set_reclong(get_stack_optional<std::string>(j, "reclong")); |
| 235 | - if (j.find("year") != j.end() && !std::regex_match(j.at("year").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 235 | + if (j.find("year") != j.end() && !std::regex_match(j.at("year").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 236 | 236 | if (j.find("year") != j.end() && j.at("year").is_null()) throw std::runtime_error("Unexpected null"); |
| 237 | 237 | x.set_year(get_stack_optional<std::string>(j, "year")); |
| 238 | 238 | } |
Mphpdefault / TopLevel.php+4 −0
| @@ -634,6 +634,10 @@ class TopLevel { | ||
| 634 | 634 | public static function fromYear(?string $value): ?DateTime { |
| 635 | 635 | if (!is_null($value)) { |
| 636 | 636 | $tmp = new DateTime($value); |
| 637 | + $errors = DateTime::getLastErrors(); | |
| 638 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 639 | + throw new Exception('Invalid date-time'); | |
| 640 | + } | |
| 637 | 641 | if (!is_a($tmp, 'DateTime')) { |
| 638 | 642 | throw new Exception('Attribute Error:TopLevel::'); |
| 639 | 643 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -187,7 +187,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 187 | 187 | let decoder = JSONDecoder() |
| 188 | 188 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 189 | 189 | let container = try decoder.singleValueContainer() |
| 190 | - let dateStr = try container.decode(String.self) | |
| 190 | + let dateStr = try container.decode(String.self).uppercased() | |
| 191 | 191 | |
| 192 | 192 | let formatter = DateFormatter() |
| 193 | 193 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/b6f2c.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/b6fe5.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -67,7 +67,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 67 | 67 | let decoder = JSONDecoder() |
| 68 | 68 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 69 | 69 | let container = try decoder.singleValueContainer() |
| 70 | - let dateStr = try container.decode(String.self) | |
| 70 | + let dateStr = try container.decode(String.self).uppercased() | |
| 71 | 71 | |
| 72 | 72 | let formatter = DateFormatter() |
| 73 | 73 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/b9f64.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/bb1ec.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/be234.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -937,7 +937,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 937 | 937 | let decoder = JSONDecoder() |
| 938 | 938 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 939 | 939 | let container = try decoder.singleValueContainer() |
| 940 | - let dateStr = try container.decode(String.self) | |
| 940 | + let dateStr = try container.decode(String.self).uppercased() | |
| 941 | 941 | |
| 942 | 942 | let formatter = DateFormatter() |
| 943 | 943 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/c0356.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -159,7 +159,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 159 | 159 | let decoder = JSONDecoder() |
| 160 | 160 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 161 | 161 | let container = try decoder.singleValueContainer() |
| 162 | - let dateStr = try container.decode(String.self) | |
| 162 | + let dateStr = try container.decode(String.self).uppercased() | |
| 163 | 163 | |
| 164 | 164 | let formatter = DateFormatter() |
| 165 | 165 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/c0a3a.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -271,7 +271,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 271 | 271 | let decoder = JSONDecoder() |
| 272 | 272 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 273 | 273 | let container = try decoder.singleValueContainer() |
| 274 | - let dateStr = try container.decode(String.self) | |
| 274 | + let dateStr = try container.decode(String.self).uppercased() | |
| 275 | 275 | |
| 276 | 276 | let formatter = DateFormatter() |
| 277 | 277 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/c3303.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -726,7 +726,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 726 | 726 | let decoder = JSONDecoder() |
| 727 | 727 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 728 | 728 | let container = try decoder.singleValueContainer() |
| 729 | - let dateStr = try container.decode(String.self) | |
| 729 | + let dateStr = try container.decode(String.self).uppercased() | |
| 730 | 730 | |
| 731 | 731 | let formatter = DateFormatter() |
| 732 | 732 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/c6cfd.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/c8c7e.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -240,7 +240,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 240 | 240 | let decoder = JSONDecoder() |
| 241 | 241 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 242 | 242 | let container = try decoder.singleValueContainer() |
| 243 | - let dateStr = try container.decode(String.self) | |
| 243 | + let dateStr = try container.decode(String.self).uppercased() | |
| 244 | 244 | |
| 245 | 245 | let formatter = DateFormatter() |
| 246 | 246 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/cb0cc.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -180,7 +180,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 180 | 180 | let decoder = JSONDecoder() |
| 181 | 181 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 182 | 182 | let container = try decoder.singleValueContainer() |
| 183 | - let dateStr = try container.decode(String.self) | |
| 183 | + let dateStr = try container.decode(String.self).uppercased() | |
| 184 | 184 | |
| 185 | 185 | let formatter = DateFormatter() |
| 186 | 186 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/cb81e.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -115,7 +115,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 115 | 115 | let decoder = JSONDecoder() |
| 116 | 116 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 117 | 117 | let container = try decoder.singleValueContainer() |
| 118 | - let dateStr = try container.decode(String.self) | |
| 118 | + let dateStr = try container.decode(String.self).uppercased() | |
| 119 | 119 | |
| 120 | 120 | let formatter = DateFormatter() |
| 121 | 121 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/ccd18.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -271,7 +271,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 271 | 271 | let decoder = JSONDecoder() |
| 272 | 272 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 273 | 273 | let container = try decoder.singleValueContainer() |
| 274 | - let dateStr = try container.decode(String.self) | |
| 274 | + let dateStr = try container.decode(String.self).uppercased() | |
| 275 | 275 | |
| 276 | 276 | let formatter = DateFormatter() |
| 277 | 277 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/cd238.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -271,7 +271,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 271 | 271 | let decoder = JSONDecoder() |
| 272 | 272 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 273 | 273 | let container = try decoder.singleValueContainer() |
| 274 | - let dateStr = try container.decode(String.self) | |
| 274 | + let dateStr = try container.decode(String.self).uppercased() | |
| 275 | 275 | |
| 276 | 276 | let formatter = DateFormatter() |
| 277 | 277 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/cd463.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/cda6c.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -240,7 +240,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 240 | 240 | let decoder = JSONDecoder() |
| 241 | 241 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 242 | 242 | let container = try decoder.singleValueContainer() |
| 243 | - let dateStr = try container.decode(String.self) | |
| 243 | + let dateStr = try container.decode(String.self).uppercased() | |
| 244 | 244 | |
| 245 | 245 | let formatter = DateFormatter() |
| 246 | 246 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/cf0d8.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -711,7 +711,7 @@ namespace quicktype { | ||
| 711 | 711 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 712 | 712 | if (j.find("count") != j.end() && !j.at("count").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 713 | 713 | x.set_count(j.at("count").get<int64_t>()); |
| 714 | - if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 714 | + if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 715 | 715 | x.set_created(j.at("created").get<std::string>()); |
| 716 | 716 | x.set_lang(j.at("lang").get<std::string>()); |
| 717 | 717 | x.set_results(j.at("results").get<Results>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -217,7 +217,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 217 | 217 | if (self = [super init]) { |
| 218 | 218 | if (![dict[@"count"] isKindOfClass:NSNumber.class]) return nil; |
| 219 | 219 | if ([dict[@"count"] doubleValue] != [dict[@"count"] longLongValue]) return nil; |
| 220 | - if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 220 | + if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 221 | + if (dict[@"created"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created"] substringToIndex:10]]) return nil; | |
| 221 | 222 | if (![dict[@"created"] isKindOfClass:NSString.class]) return nil; |
| 222 | 223 | if (![dict[@"lang"] isKindOfClass:NSString.class]) return nil; |
| 223 | 224 | if (![dict[@"results"] isKindOfClass:NSDictionary.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -178,6 +178,10 @@ class Query { | ||
| 178 | 178 | */ |
| 179 | 179 | public static function fromCreated(string $value): DateTime { |
| 180 | 180 | $tmp = new DateTime($value); |
| 181 | + $errors = DateTime::getLastErrors(); | |
| 182 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 183 | + throw new Exception('Invalid date-time'); | |
| 184 | + } | |
| 181 | 185 | if (!is_a($tmp, 'DateTime')) { |
| 182 | 186 | throw new Exception('Attribute Error:Query::'); |
| 183 | 187 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -811,7 +811,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 811 | 811 | let decoder = JSONDecoder() |
| 812 | 812 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 813 | 813 | let container = try decoder.singleValueContainer() |
| 814 | - let dateStr = try container.decode(String.self) | |
| 814 | + let dateStr = try container.decode(String.self).uppercased() | |
| 815 | 815 | |
| 816 | 816 | let formatter = DateFormatter() |
| 817 | 817 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/cfbce.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/d0908.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +15 −5test/inputs/json/misc/d23d5.json
Mcplusplusdefault / quicktype.hpp+2 −2
| @@ -205,11 +205,11 @@ namespace quicktype { | ||
| 205 | 205 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 206 | 206 | j.at("acronym"); |
| 207 | 207 | x.set_acronym(get_stack_optional<std::string>(j, "acronym")); |
| 208 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 208 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 209 | 209 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 210 | 210 | x.set_id(j.at("id").get<std::string>()); |
| 211 | 211 | x.set_name(j.at("name").get<std::string>()); |
| 212 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 212 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 213 | 213 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 214 | 214 | x.set_uri(j.at("uri").get<std::string>()); |
| 215 | 215 | } |
Mobjective-cdefault / QTTopLevel.m+4 −2
| @@ -228,11 +228,13 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 228 | 228 | { |
| 229 | 229 | if (self = [super init]) { |
| 230 | 230 | if (!dict[@"acronym"]) return nil; |
| 231 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 231 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 232 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 232 | 233 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 233 | 234 | if (![dict[@"id"] isKindOfClass:NSString.class]) return nil; |
| 234 | 235 | if (![dict[@"name"] isKindOfClass:NSString.class]) return nil; |
| 235 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 236 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 237 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 236 | 238 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 237 | 239 | if (![dict[@"uri"] isKindOfClass:NSString.class]) return nil; |
| 238 | 240 | [self setValuesForKeysWithDictionary:dict]; |
Mphpdefault / TopLevel.php+8 −0
| @@ -593,6 +593,10 @@ class Result { | ||
| 593 | 593 | */ |
| 594 | 594 | public static function fromCreatedAt(string $value): DateTime { |
| 595 | 595 | $tmp = new DateTime($value); |
| 596 | + $errors = DateTime::getLastErrors(); | |
| 597 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 598 | + throw new Exception('Invalid date-time'); | |
| 599 | + } | |
| 596 | 600 | if (!is_a($tmp, 'DateTime')) { |
| 597 | 601 | throw new Exception('Attribute Error:Result::'); |
| 598 | 602 | } |
| @@ -741,6 +745,10 @@ class Result { | ||
| 741 | 745 | */ |
| 742 | 746 | public static function fromUpdatedAt(string $value): DateTime { |
| 743 | 747 | $tmp = new DateTime($value); |
| 748 | + $errors = DateTime::getLastErrors(); | |
| 749 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 750 | + throw new Exception('Invalid date-time'); | |
| 751 | + } | |
| 744 | 752 | if (!is_a($tmp, 'DateTime')) { |
| 745 | 753 | throw new Exception('Attribute Error:Result::'); |
| 746 | 754 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -186,7 +186,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 186 | 186 | let decoder = JSONDecoder() |
| 187 | 187 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 188 | 188 | let container = try decoder.singleValueContainer() |
| 189 | - let dateStr = try container.decode(String.self) | |
| 189 | + let dateStr = try container.decode(String.self).uppercased() | |
| 190 | 190 | |
| 191 | 191 | let formatter = DateFormatter() |
| 192 | 192 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/dbfb3.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -716,7 +716,7 @@ namespace quicktype { | ||
| 716 | 716 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 717 | 717 | if (j.find("count") != j.end() && !j.at("count").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 718 | 718 | x.set_count(j.at("count").get<int64_t>()); |
| 719 | - if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 719 | + if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 720 | 720 | x.set_created(j.at("created").get<std::string>()); |
| 721 | 721 | x.set_lang(j.at("lang").get<std::string>()); |
| 722 | 722 | x.set_results(j.at("results").get<Results>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -244,7 +244,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 244 | 244 | if (self = [super init]) { |
| 245 | 245 | if (![dict[@"count"] isKindOfClass:NSNumber.class]) return nil; |
| 246 | 246 | if ([dict[@"count"] doubleValue] != [dict[@"count"] longLongValue]) return nil; |
| 247 | - if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 247 | + if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 248 | + if (dict[@"created"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created"] substringToIndex:10]]) return nil; | |
| 248 | 249 | if (![dict[@"created"] isKindOfClass:NSString.class]) return nil; |
| 249 | 250 | if (![dict[@"lang"] isKindOfClass:NSString.class]) return nil; |
| 250 | 251 | if (![dict[@"results"] isKindOfClass:NSDictionary.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -178,6 +178,10 @@ class Query { | ||
| 178 | 178 | */ |
| 179 | 179 | public static function fromCreated(string $value): DateTime { |
| 180 | 180 | $tmp = new DateTime($value); |
| 181 | + $errors = DateTime::getLastErrors(); | |
| 182 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 183 | + throw new Exception('Invalid date-time'); | |
| 184 | + } | |
| 181 | 185 | if (!is_a($tmp, 'DateTime')) { |
| 182 | 186 | throw new Exception('Attribute Error:Query::'); |
| 183 | 187 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -816,7 +816,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 816 | 816 | let decoder = JSONDecoder() |
| 817 | 817 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 818 | 818 | let container = try decoder.singleValueContainer() |
| 819 | - let dateStr = try container.decode(String.self) | |
| 819 | + let dateStr = try container.decode(String.self).uppercased() | |
| 820 | 820 | |
| 821 | 821 | let formatter = DateFormatter() |
| 822 | 822 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/dc44f.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -424,7 +424,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 424 | 424 | let decoder = JSONDecoder() |
| 425 | 425 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 426 | 426 | let container = try decoder.singleValueContainer() |
| 427 | - let dateStr = try container.decode(String.self) | |
| 427 | + let dateStr = try container.decode(String.self).uppercased() | |
| 428 | 428 | |
| 429 | 429 | let formatter = DateFormatter() |
| 430 | 430 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/dd1ce.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -424,7 +424,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 424 | 424 | let decoder = JSONDecoder() |
| 425 | 425 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 426 | 426 | let container = try decoder.singleValueContainer() |
| 427 | - let dateStr = try container.decode(String.self) | |
| 427 | + let dateStr = try container.decode(String.self).uppercased() | |
| 428 | 428 | |
| 429 | 429 | let formatter = DateFormatter() |
| 430 | 430 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/dec3a.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -467,7 +467,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 467 | 467 | let decoder = JSONDecoder() |
| 468 | 468 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 469 | 469 | let container = try decoder.singleValueContainer() |
| 470 | - let dateStr = try container.decode(String.self) | |
| 470 | + let dateStr = try container.decode(String.self).uppercased() | |
| 471 | 471 | |
| 472 | 472 | let formatter = DateFormatter() |
| 473 | 473 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/df957.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -711,7 +711,7 @@ namespace quicktype { | ||
| 711 | 711 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 712 | 712 | if (j.find("count") != j.end() && !j.at("count").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 713 | 713 | x.set_count(j.at("count").get<int64_t>()); |
| 714 | - if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 714 | + if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 715 | 715 | x.set_created(j.at("created").get<std::string>()); |
| 716 | 716 | x.set_lang(j.at("lang").get<std::string>()); |
| 717 | 717 | x.set_results(j.at("results").get<Results>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -217,7 +217,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 217 | 217 | if (self = [super init]) { |
| 218 | 218 | if (![dict[@"count"] isKindOfClass:NSNumber.class]) return nil; |
| 219 | 219 | if ([dict[@"count"] doubleValue] != [dict[@"count"] longLongValue]) return nil; |
| 220 | - if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 220 | + if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 221 | + if (dict[@"created"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created"] substringToIndex:10]]) return nil; | |
| 221 | 222 | if (![dict[@"created"] isKindOfClass:NSString.class]) return nil; |
| 222 | 223 | if (![dict[@"lang"] isKindOfClass:NSString.class]) return nil; |
| 223 | 224 | if (![dict[@"results"] isKindOfClass:NSDictionary.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -178,6 +178,10 @@ class Query { | ||
| 178 | 178 | */ |
| 179 | 179 | public static function fromCreated(string $value): DateTime { |
| 180 | 180 | $tmp = new DateTime($value); |
| 181 | + $errors = DateTime::getLastErrors(); | |
| 182 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 183 | + throw new Exception('Invalid date-time'); | |
| 184 | + } | |
| 181 | 185 | if (!is_a($tmp, 'DateTime')) { |
| 182 | 186 | throw new Exception('Attribute Error:Query::'); |
| 183 | 187 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -811,7 +811,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 811 | 811 | let decoder = JSONDecoder() |
| 812 | 812 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 813 | 813 | let container = try decoder.singleValueContainer() |
| 814 | - let dateStr = try container.decode(String.self) | |
| 814 | + let dateStr = try container.decode(String.self).uppercased() | |
| 815 | 815 | |
| 816 | 816 | let formatter = DateFormatter() |
| 817 | 817 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/e0ac7.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -725,7 +725,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 725 | 725 | let decoder = JSONDecoder() |
| 726 | 726 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 727 | 727 | let container = try decoder.singleValueContainer() |
| 728 | - let dateStr = try container.decode(String.self) | |
| 728 | + let dateStr = try container.decode(String.self).uppercased() | |
| 729 | 729 | |
| 730 | 730 | let formatter = DateFormatter() |
| 731 | 731 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/misc/e2915.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -716,7 +716,7 @@ namespace quicktype { | ||
| 716 | 716 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 717 | 717 | if (j.find("count") != j.end() && !j.at("count").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 718 | 718 | x.set_count(j.at("count").get<int64_t>()); |
| 719 | - if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 719 | + if (j.find("created") != j.end() && !std::regex_match(j.at("created").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 720 | 720 | x.set_created(j.at("created").get<std::string>()); |
| 721 | 721 | x.set_lang(j.at("lang").get<std::string>()); |
| 722 | 722 | x.set_results(j.at("results").get<Results>()); |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -242,7 +242,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 242 | 242 | if (self = [super init]) { |
| 243 | 243 | if (![dict[@"count"] isKindOfClass:NSNumber.class]) return nil; |
| 244 | 244 | if ([dict[@"count"] doubleValue] != [dict[@"count"] longLongValue]) return nil; |
| 245 | - if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 245 | + if (dict[@"created"] && [dict[@"created"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 246 | + if (dict[@"created"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created"] substringToIndex:10]]) return nil; | |
| 246 | 247 | if (![dict[@"created"] isKindOfClass:NSString.class]) return nil; |
| 247 | 248 | if (![dict[@"lang"] isKindOfClass:NSString.class]) return nil; |
| 248 | 249 | if (![dict[@"results"] isKindOfClass:NSDictionary.class]) return nil; |
Mphpdefault / TopLevel.php+4 −0
| @@ -178,6 +178,10 @@ class Query { | ||
| 178 | 178 | */ |
| 179 | 179 | public static function fromCreated(string $value): DateTime { |
| 180 | 180 | $tmp = new DateTime($value); |
| 181 | + $errors = DateTime::getLastErrors(); | |
| 182 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 183 | + throw new Exception('Invalid date-time'); | |
| 184 | + } | |
| 181 | 185 | if (!is_a($tmp, 'DateTime')) { |
| 182 | 186 | throw new Exception('Attribute Error:Query::'); |
| 183 | 187 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -815,7 +815,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 815 | 815 | let decoder = JSONDecoder() |
| 816 | 816 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 817 | 817 | let container = try decoder.singleValueContainer() |
| 818 | - let dateStr = try container.decode(String.self) | |
| 818 | + let dateStr = try container.decode(String.self).uppercased() | |
| 819 | 819 | |
| 820 | 820 | let formatter = DateFormatter() |
| 821 | 821 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/e2a58.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -86,7 +86,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 86 | 86 | let decoder = JSONDecoder() |
| 87 | 87 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 88 | 88 | let container = try decoder.singleValueContainer() |
| 89 | - let dateStr = try container.decode(String.self) | |
| 89 | + let dateStr = try container.decode(String.self).uppercased() | |
| 90 | 90 | |
| 91 | 91 | let formatter = DateFormatter() |
| 92 | 92 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/e324e.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -671,7 +671,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 671 | 671 | let decoder = JSONDecoder() |
| 672 | 672 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 673 | 673 | let container = try decoder.singleValueContainer() |
| 674 | - let dateStr = try container.decode(String.self) | |
| 674 | + let dateStr = try container.decode(String.self).uppercased() | |
| 675 | 675 | |
| 676 | 676 | let formatter = DateFormatter() |
| 677 | 677 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/e53b5.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -240,7 +240,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 240 | 240 | let decoder = JSONDecoder() |
| 241 | 241 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 242 | 242 | let container = try decoder.singleValueContainer() |
| 243 | - let dateStr = try container.decode(String.self) | |
| 243 | + let dateStr = try container.decode(String.self).uppercased() | |
| 244 | 244 | |
| 245 | 245 | let formatter = DateFormatter() |
| 246 | 246 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/e64a0.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -166,7 +166,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 166 | 166 | let decoder = JSONDecoder() |
| 167 | 167 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 168 | 168 | let container = try decoder.singleValueContainer() |
| 169 | - let dateStr = try container.decode(String.self) | |
| 169 | + let dateStr = try container.decode(String.self).uppercased() | |
| 170 | 170 | |
| 171 | 171 | let formatter = DateFormatter() |
| 172 | 172 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/e8a0b.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -106,7 +106,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 106 | 106 | let decoder = JSONDecoder() |
| 107 | 107 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 108 | 108 | let container = try decoder.singleValueContainer() |
| 109 | - let dateStr = try container.decode(String.self) | |
| 109 | + let dateStr = try container.decode(String.self).uppercased() | |
| 110 | 110 | |
| 111 | 111 | let formatter = DateFormatter() |
| 112 | 112 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/e8b04.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -1703,7 +1703,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 1703 | 1703 | let decoder = JSONDecoder() |
| 1704 | 1704 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 1705 | 1705 | let container = try decoder.singleValueContainer() |
| 1706 | - let dateStr = try container.decode(String.self) | |
| 1706 | + let dateStr = try container.decode(String.self).uppercased() | |
| 1707 | 1707 | |
| 1708 | 1708 | let formatter = DateFormatter() |
| 1709 | 1709 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/ed095.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -37,7 +37,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 37 | 37 | let decoder = JSONDecoder() |
| 38 | 38 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 39 | 39 | let container = try decoder.singleValueContainer() |
| 40 | - let dateStr = try container.decode(String.self) | |
| 40 | + let dateStr = try container.decode(String.self).uppercased() | |
| 41 | 41 | |
| 42 | 42 | let formatter = DateFormatter() |
| 43 | 43 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/f22f5.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -506,7 +506,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 506 | 506 | let decoder = JSONDecoder() |
| 507 | 507 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 508 | 508 | let container = try decoder.singleValueContainer() |
| 509 | - let dateStr = try container.decode(String.self) | |
| 509 | + let dateStr = try container.decode(String.self).uppercased() | |
| 510 | 510 | |
| 511 | 511 | let formatter = DateFormatter() |
| 512 | 512 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/f3139.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -86,7 +86,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 86 | 86 | let decoder = JSONDecoder() |
| 87 | 87 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 88 | 88 | let container = try decoder.singleValueContainer() |
| 89 | - let dateStr = try container.decode(String.self) | |
| 89 | + let dateStr = try container.decode(String.self).uppercased() | |
| 90 | 90 | |
| 91 | 91 | let formatter = DateFormatter() |
| 92 | 92 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/f3edf.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -106,7 +106,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 106 | 106 | let decoder = JSONDecoder() |
| 107 | 107 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 108 | 108 | let container = try decoder.singleValueContainer() |
| 109 | - let dateStr = try container.decode(String.self) | |
| 109 | + let dateStr = try container.decode(String.self).uppercased() | |
| 110 | 110 | |
| 111 | 111 | let formatter = DateFormatter() |
| 112 | 112 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/f466a.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -106,7 +106,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 106 | 106 | let decoder = JSONDecoder() |
| 107 | 107 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 108 | 108 | let container = try decoder.singleValueContainer() |
| 109 | - let dateStr = try container.decode(String.self) | |
| 109 | + let dateStr = try container.decode(String.self).uppercased() | |
| 110 | 110 | |
| 111 | 111 | let formatter = DateFormatter() |
| 112 | 112 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/f6a65.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -733,7 +733,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 733 | 733 | let decoder = JSONDecoder() |
| 734 | 734 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 735 | 735 | let container = try decoder.singleValueContainer() |
| 736 | - let dateStr = try container.decode(String.self) | |
| 736 | + let dateStr = try container.decode(String.self).uppercased() | |
| 737 | 737 | |
| 738 | 738 | let formatter = DateFormatter() |
| 739 | 739 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/f74d5.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -864,7 +864,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 864 | 864 | let decoder = JSONDecoder() |
| 865 | 865 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 866 | 866 | let container = try decoder.singleValueContainer() |
| 867 | - let dateStr = try container.decode(String.self) | |
| 867 | + let dateStr = try container.decode(String.self).uppercased() | |
| 868 | 868 | |
| 869 | 869 | let formatter = DateFormatter() |
| 870 | 870 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/f82d9.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -751,7 +751,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 751 | 751 | let decoder = JSONDecoder() |
| 752 | 752 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 753 | 753 | let container = try decoder.singleValueContainer() |
| 754 | - let dateStr = try container.decode(String.self) | |
| 754 | + let dateStr = try container.decode(String.self).uppercased() | |
| 755 | 755 | |
| 756 | 756 | let formatter = DateFormatter() |
| 757 | 757 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/f974d.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -71,7 +71,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 71 | 71 | let decoder = JSONDecoder() |
| 72 | 72 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 73 | 73 | let container = try decoder.singleValueContainer() |
| 74 | - let dateStr = try container.decode(String.self) | |
| 74 | + let dateStr = try container.decode(String.self).uppercased() | |
| 75 | 75 | |
| 76 | 76 | let formatter = DateFormatter() |
| 77 | 77 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/faff5.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/fcca3.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -1676,7 +1676,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 1676 | 1676 | let decoder = JSONDecoder() |
| 1677 | 1677 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 1678 | 1678 | let container = try decoder.singleValueContainer() |
| 1679 | - let dateStr = try container.decode(String.self) | |
| 1679 | + let dateStr = try container.decode(String.self).uppercased() | |
| 1680 | 1680 | |
| 1681 | 1681 | let formatter = DateFormatter() |
| 1682 | 1682 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/misc/fd329.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -163,7 +163,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 163 | 163 | let decoder = JSONDecoder() |
| 164 | 164 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 165 | 165 | let container = try decoder.singleValueContainer() |
| 166 | - let dateStr = try container.decode(String.self) | |
| 166 | + let dateStr = try container.decode(String.self).uppercased() | |
| 167 | 167 | |
| 168 | 168 | let formatter = DateFormatter() |
| 169 | 169 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/blns-object.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -2519,7 +2519,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2519 | 2519 | let decoder = JSONDecoder() |
| 2520 | 2520 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2521 | 2521 | let container = try decoder.singleValueContainer() |
| 2522 | - let dateStr = try container.decode(String.self) | |
| 2522 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2523 | 2523 | |
| 2524 | 2524 | let formatter = DateFormatter() |
| 2525 | 2525 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/bug2037.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -186,7 +186,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 186 | 186 | let decoder = JSONDecoder() |
| 187 | 187 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 188 | 188 | let container = try decoder.singleValueContainer() |
| 189 | - let dateStr = try container.decode(String.self) | |
| 189 | + let dateStr = try container.decode(String.self).uppercased() | |
| 190 | 190 | |
| 191 | 191 | let formatter = DateFormatter() |
| 192 | 192 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/bug2521.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
2 generated files · +5 −1test/inputs/json/priority/bug2590.json
Mphpdefault / TopLevel.php+4 −0
| @@ -140,6 +140,10 @@ class Invoice { | ||
| 140 | 140 | public static function fromCreatedAt(?string $value): ?DateTime { |
| 141 | 141 | if (!is_null($value)) { |
| 142 | 142 | $tmp = new DateTime($value); |
| 143 | + $errors = DateTime::getLastErrors(); | |
| 144 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 145 | + throw new Exception('Invalid date-time'); | |
| 146 | + } | |
| 143 | 147 | if (!is_a($tmp, 'DateTime')) { |
| 144 | 148 | throw new Exception('Attribute Error:Invoice::'); |
| 145 | 149 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -107,7 +107,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 107 | 107 | let decoder = JSONDecoder() |
| 108 | 108 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 109 | 109 | let container = try decoder.singleValueContainer() |
| 110 | - let dateStr = try container.decode(String.self) | |
| 110 | + let dateStr = try container.decode(String.self).uppercased() | |
| 111 | 111 | |
| 112 | 112 | let formatter = DateFormatter() |
| 113 | 113 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +8 −3test/inputs/json/priority/bug2663.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -63,7 +63,7 @@ namespace quicktype { | ||
| 63 | 63 | inline void from_json(const json & j, TopLevel& x) { |
| 64 | 64 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 65 | 65 | x.set_birthday(j.at("birthday").get<std::string>()); |
| 66 | - if (j.find("lastSeen") != j.end() && !std::regex_match(j.at("lastSeen").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 66 | + if (j.find("lastSeen") != j.end() && !std::regex_match(j.at("lastSeen").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 67 | 67 | x.set_last_seen(j.at("lastSeen").get<std::string>()); |
| 68 | 68 | x.set_name(j.at("name").get<std::string>()); |
| 69 | 69 | } |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -79,7 +79,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 79 | 79 | { |
| 80 | 80 | if (self = [super init]) { |
| 81 | 81 | if (![dict[@"birthday"] isKindOfClass:NSString.class]) return nil; |
| 82 | - if (dict[@"lastSeen"] && [dict[@"lastSeen"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 82 | + if (dict[@"lastSeen"] && [dict[@"lastSeen"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 83 | + if (dict[@"lastSeen"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"lastSeen"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"lastSeen"] substringToIndex:10]]) return nil; | |
| 83 | 84 | if (![dict[@"lastSeen"] isKindOfClass:NSString.class]) return nil; |
| 84 | 85 | if (![dict[@"name"] isKindOfClass:NSString.class]) return nil; |
| 85 | 86 | [self setValuesForKeysWithDictionary:dict]; |
Mphpdefault / TopLevel.php+4 −0
| @@ -73,6 +73,10 @@ class TopLevel { | ||
| 73 | 73 | */ |
| 74 | 74 | public static function fromLastSeen(string $value): DateTime { |
| 75 | 75 | $tmp = new DateTime($value); |
| 76 | + $errors = DateTime::getLastErrors(); | |
| 77 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 78 | + throw new Exception('Invalid date-time'); | |
| 79 | + } | |
| 76 | 80 | if (!is_a($tmp, 'DateTime')) { |
| 77 | 81 | throw new Exception('Attribute Error:TopLevel::'); |
| 78 | 82 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/bug2793.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -150,7 +150,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 150 | 150 | let decoder = JSONDecoder() |
| 151 | 151 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 152 | 152 | let container = try decoder.singleValueContainer() |
| 153 | - let dateStr = try container.decode(String.self) | |
| 153 | + let dateStr = try container.decode(String.self).uppercased() | |
| 154 | 154 | |
| 155 | 155 | let formatter = DateFormatter() |
| 156 | 156 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/bug427.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -4016,7 +4016,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 4016 | 4016 | let decoder = JSONDecoder() |
| 4017 | 4017 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 4018 | 4018 | let container = try decoder.singleValueContainer() |
| 4019 | - let dateStr = try container.decode(String.self) | |
| 4019 | + let dateStr = try container.decode(String.self).uppercased() | |
| 4020 | 4020 | |
| 4021 | 4021 | let formatter = DateFormatter() |
| 4022 | 4022 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/bug790.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -83,7 +83,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 83 | 83 | let decoder = JSONDecoder() |
| 84 | 84 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 85 | 85 | let container = try decoder.singleValueContainer() |
| 86 | - let dateStr = try container.decode(String.self) | |
| 86 | + let dateStr = try container.decode(String.self).uppercased() | |
| 87 | 87 | |
| 88 | 88 | let formatter = DateFormatter() |
| 89 | 89 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/bug855-short.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -98,7 +98,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 98 | 98 | let decoder = JSONDecoder() |
| 99 | 99 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 100 | 100 | let container = try decoder.singleValueContainer() |
| 101 | - let dateStr = try container.decode(String.self) | |
| 101 | + let dateStr = try container.decode(String.self).uppercased() | |
| 102 | 102 | |
| 103 | 103 | let formatter = DateFormatter() |
| 104 | 104 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/bug863.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -395,7 +395,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 395 | 395 | let decoder = JSONDecoder() |
| 396 | 396 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 397 | 397 | let container = try decoder.singleValueContainer() |
| 398 | - let dateStr = try container.decode(String.self) | |
| 398 | + let dateStr = try container.decode(String.self).uppercased() | |
| 399 | 399 | |
| 400 | 400 | let formatter = DateFormatter() |
| 401 | 401 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/coin-pairs.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -131,7 +131,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 131 | 131 | let decoder = JSONDecoder() |
| 132 | 132 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 133 | 133 | let container = try decoder.singleValueContainer() |
| 134 | - let dateStr = try container.decode(String.self) | |
| 134 | + let dateStr = try container.decode(String.self).uppercased() | |
| 135 | 135 | |
| 136 | 136 | let formatter = DateFormatter() |
| 137 | 137 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
15 generated files · +21 −15test/inputs/json/priority/combinations1.json
Mswift-sendable-objective-cdefault / quicktype.swift+1 −1
| @@ -3124,7 +3124,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3124 | 3124 | let decoder = JSONDecoder() |
| 3125 | 3125 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3126 | 3126 | let container = try decoder.singleValueContainer() |
| 3127 | - let dateStr = try container.decode(String.self) | |
| 3127 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3128 | 3128 | |
| 3129 | 3129 | let formatter = DateFormatter() |
| 3130 | 3130 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftaccess-level-internal--a653a863c206 / quicktype.swift+1 −1
| @@ -2780,7 +2780,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2780 | 2780 | let decoder = JSONDecoder() |
| 2781 | 2781 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2782 | 2782 | let container = try decoder.singleValueContainer() |
| 2783 | - let dateStr = try container.decode(String.self) | |
| 2783 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2784 | 2784 | |
| 2785 | 2785 | let formatter = DateFormatter() |
| 2786 | 2786 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftaccess-level-public--bc6fc37ec004 / quicktype.swift+1 −1
| @@ -3110,7 +3110,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3110 | 3110 | let decoder = JSONDecoder() |
| 3111 | 3111 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3112 | 3112 | let container = try decoder.singleValueContainer() |
| 3113 | - let dateStr = try container.decode(String.self) | |
| 3113 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3114 | 3114 | |
| 3115 | 3115 | let formatter = DateFormatter() |
| 3116 | 3116 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftcoding-keys-false--33058e42a49b / quicktype.swift+1 −1
| @@ -2780,7 +2780,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2780 | 2780 | let decoder = JSONDecoder() |
| 2781 | 2781 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2782 | 2782 | let container = try decoder.singleValueContainer() |
| 2783 | - let dateStr = try container.decode(String.self) | |
| 2783 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2784 | 2784 | |
| 2785 | 2785 | let formatter = DateFormatter() |
| 2786 | 2786 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftcoding-keys-protocol-CaseIterable--169323764eaa / quicktype.swift+1 −1
| @@ -2780,7 +2780,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2780 | 2780 | let decoder = JSONDecoder() |
| 2781 | 2781 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2782 | 2782 | let container = try decoder.singleValueContainer() |
| 2783 | - let dateStr = try container.decode(String.self) | |
| 2783 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2784 | 2784 | |
| 2785 | 2785 | let formatter = DateFormatter() |
| 2786 | 2786 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftdefault / quicktype.swift+1 −1
| @@ -2780,7 +2780,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2780 | 2780 | let decoder = JSONDecoder() |
| 2781 | 2781 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2782 | 2782 | let container = try decoder.singleValueContainer() |
| 2783 | - let dateStr = try container.decode(String.self) | |
| 2783 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2784 | 2784 | |
| 2785 | 2785 | let formatter = DateFormatter() |
| 2786 | 2786 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftdensity-dense--3bfb4c22cfd0 / quicktype.swift+1 −1
| @@ -2394,7 +2394,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2394 | 2394 | let decoder = JSONDecoder() |
| 2395 | 2395 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2396 | 2396 | let container = try decoder.singleValueContainer() |
| 2397 | - let dateStr = try container.decode(String.self) | |
| 2397 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2398 | 2398 | |
| 2399 | 2399 | let formatter = DateFormatter() |
| 2400 | 2400 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftfinal-classes-true__struct-or-class-class--d3c62ec7414d / quicktype.swift+1 −1
| @@ -3124,7 +3124,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3124 | 3124 | let decoder = JSONDecoder() |
| 3125 | 3125 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3126 | 3126 | let container = try decoder.singleValueContainer() |
| 3127 | - let dateStr = try container.decode(String.self) | |
| 3127 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3128 | 3128 | |
| 3129 | 3129 | let formatter = DateFormatter() |
| 3130 | 3130 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftmutable-properties-true--a9feb4120f94 / quicktype.swift+1 −1
| @@ -2780,7 +2780,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2780 | 2780 | let decoder = JSONDecoder() |
| 2781 | 2781 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2782 | 2782 | let container = try decoder.singleValueContainer() |
| 2783 | - let dateStr = try container.decode(String.self) | |
| 2783 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2784 | 2784 | |
| 2785 | 2785 | let formatter = DateFormatter() |
| 2786 | 2786 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftprotocol-equatable--bd9068f466c1 / quicktype.swift+1 −1
| @@ -2864,7 +2864,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2864 | 2864 | let decoder = JSONDecoder() |
| 2865 | 2865 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2866 | 2866 | let container = try decoder.singleValueContainer() |
| 2867 | - let dateStr = try container.decode(String.self) | |
| 2867 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2868 | 2868 | |
| 2869 | 2869 | let formatter = DateFormatter() |
| 2870 | 2870 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftprotocol-hashable--739b516c7897 / quicktype.swift+1 −1
| @@ -2864,7 +2864,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2864 | 2864 | let decoder = JSONDecoder() |
| 2865 | 2865 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2866 | 2866 | let container = try decoder.singleValueContainer() |
| 2867 | - let dateStr = try container.decode(String.self) | |
| 2867 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2868 | 2868 | |
| 2869 | 2869 | let formatter = DateFormatter() |
| 2870 | 2870 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsendable-true__struct-or-class-class--265b1fe2e96e / quicktype.swift+1 −1
| @@ -3124,7 +3124,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3124 | 3124 | let decoder = JSONDecoder() |
| 3125 | 3125 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3126 | 3126 | let container = try decoder.singleValueContainer() |
| 3127 | - let dateStr = try container.decode(String.self) | |
| 3127 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3128 | 3128 | |
| 3129 | 3129 | let formatter = DateFormatter() |
| 3130 | 3130 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsendable-true--1c3982c78639 / quicktype.swift+1 −1
| @@ -2780,7 +2780,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2780 | 2780 | let decoder = JSONDecoder() |
| 2781 | 2781 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2782 | 2782 | let container = try decoder.singleValueContainer() |
| 2783 | - let dateStr = try container.decode(String.self) | |
| 2783 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2784 | 2784 | |
| 2785 | 2785 | let formatter = DateFormatter() |
| 2786 | 2786 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftstruct-or-class-class--238d6c8a12d4 / quicktype.swift+1 −1
| @@ -3124,7 +3124,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3124 | 3124 | let decoder = JSONDecoder() |
| 3125 | 3125 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3126 | 3126 | let container = try decoder.singleValueContainer() |
| 3127 | - let dateStr = try container.decode(String.self) | |
| 3127 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3128 | 3128 | |
| 3129 | 3129 | let formatter = DateFormatter() |
| 3130 | 3130 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsupport-linux-false--4bd8c552e09a / quicktype.swift+7 −1
| @@ -2779,7 +2779,13 @@ enum Jacutinga: Codable { | ||
| 2779 | 2779 | func newJSONDecoder() -> JSONDecoder { |
| 2780 | 2780 | let decoder = JSONDecoder() |
| 2781 | 2781 | if #available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *) { |
| 2782 | - decoder.dateDecodingStrategy = .iso8601 | |
| 2782 | + decoder.dateDecodingStrategy = .custom { decoder in | |
| 2783 | + let dateStr = try decoder.singleValueContainer().decode(String.self).uppercased() | |
| 2784 | + let dateData = try JSONEncoder().encode(dateStr) | |
| 2785 | + let dateDecoder = JSONDecoder() | |
| 2786 | + dateDecoder.dateDecodingStrategy = .iso8601 | |
| 2787 | + return try dateDecoder.decode(Date.self, from: dateData) | |
| 2788 | + } | |
| 2783 | 2789 | } |
| 2784 | 2790 | return decoder |
| 2785 | 2791 | } |
Test case
14 generated files · +20 −14test/inputs/json/priority/combinations2.json
Mswiftaccess-level-internal--a653a863c206 / quicktype.swift+1 −1
| @@ -2544,7 +2544,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2544 | 2544 | let decoder = JSONDecoder() |
| 2545 | 2545 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2546 | 2546 | let container = try decoder.singleValueContainer() |
| 2547 | - let dateStr = try container.decode(String.self) | |
| 2547 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2548 | 2548 | |
| 2549 | 2549 | let formatter = DateFormatter() |
| 2550 | 2550 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftaccess-level-public--bc6fc37ec004 / quicktype.swift+1 −1
| @@ -2822,7 +2822,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2822 | 2822 | let decoder = JSONDecoder() |
| 2823 | 2823 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2824 | 2824 | let container = try decoder.singleValueContainer() |
| 2825 | - let dateStr = try container.decode(String.self) | |
| 2825 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2826 | 2826 | |
| 2827 | 2827 | let formatter = DateFormatter() |
| 2828 | 2828 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftcoding-keys-false--33058e42a49b / quicktype.swift+1 −1
| @@ -2544,7 +2544,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2544 | 2544 | let decoder = JSONDecoder() |
| 2545 | 2545 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2546 | 2546 | let container = try decoder.singleValueContainer() |
| 2547 | - let dateStr = try container.decode(String.self) | |
| 2547 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2548 | 2548 | |
| 2549 | 2549 | let formatter = DateFormatter() |
| 2550 | 2550 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftcoding-keys-protocol-CaseIterable--169323764eaa / quicktype.swift+1 −1
| @@ -2544,7 +2544,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2544 | 2544 | let decoder = JSONDecoder() |
| 2545 | 2545 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2546 | 2546 | let container = try decoder.singleValueContainer() |
| 2547 | - let dateStr = try container.decode(String.self) | |
| 2547 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2548 | 2548 | |
| 2549 | 2549 | let formatter = DateFormatter() |
| 2550 | 2550 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftdefault / quicktype.swift+1 −1
| @@ -2544,7 +2544,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2544 | 2544 | let decoder = JSONDecoder() |
| 2545 | 2545 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2546 | 2546 | let container = try decoder.singleValueContainer() |
| 2547 | - let dateStr = try container.decode(String.self) | |
| 2547 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2548 | 2548 | |
| 2549 | 2549 | let formatter = DateFormatter() |
| 2550 | 2550 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftdensity-dense--3bfb4c22cfd0 / quicktype.swift+1 −1
| @@ -2246,7 +2246,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2246 | 2246 | let decoder = JSONDecoder() |
| 2247 | 2247 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2248 | 2248 | let container = try decoder.singleValueContainer() |
| 2249 | - let dateStr = try container.decode(String.self) | |
| 2249 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2250 | 2250 | |
| 2251 | 2251 | let formatter = DateFormatter() |
| 2252 | 2252 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftfinal-classes-true__struct-or-class-class--d3c62ec7414d / quicktype.swift+1 −1
| @@ -2833,7 +2833,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2833 | 2833 | let decoder = JSONDecoder() |
| 2834 | 2834 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2835 | 2835 | let container = try decoder.singleValueContainer() |
| 2836 | - let dateStr = try container.decode(String.self) | |
| 2836 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2837 | 2837 | |
| 2838 | 2838 | let formatter = DateFormatter() |
| 2839 | 2839 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftmutable-properties-true--a9feb4120f94 / quicktype.swift+1 −1
| @@ -2544,7 +2544,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2544 | 2544 | let decoder = JSONDecoder() |
| 2545 | 2545 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2546 | 2546 | let container = try decoder.singleValueContainer() |
| 2547 | - let dateStr = try container.decode(String.self) | |
| 2547 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2548 | 2548 | |
| 2549 | 2549 | let formatter = DateFormatter() |
| 2550 | 2550 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftprotocol-equatable--bd9068f466c1 / quicktype.swift+1 −1
| @@ -2610,7 +2610,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2610 | 2610 | let decoder = JSONDecoder() |
| 2611 | 2611 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2612 | 2612 | let container = try decoder.singleValueContainer() |
| 2613 | - let dateStr = try container.decode(String.self) | |
| 2613 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2614 | 2614 | |
| 2615 | 2615 | let formatter = DateFormatter() |
| 2616 | 2616 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftprotocol-hashable--739b516c7897 / quicktype.swift+1 −1
| @@ -2610,7 +2610,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2610 | 2610 | let decoder = JSONDecoder() |
| 2611 | 2611 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2612 | 2612 | let container = try decoder.singleValueContainer() |
| 2613 | - let dateStr = try container.decode(String.self) | |
| 2613 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2614 | 2614 | |
| 2615 | 2615 | let formatter = DateFormatter() |
| 2616 | 2616 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsendable-true__struct-or-class-class--265b1fe2e96e / quicktype.swift+1 −1
| @@ -2833,7 +2833,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2833 | 2833 | let decoder = JSONDecoder() |
| 2834 | 2834 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2835 | 2835 | let container = try decoder.singleValueContainer() |
| 2836 | - let dateStr = try container.decode(String.self) | |
| 2836 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2837 | 2837 | |
| 2838 | 2838 | let formatter = DateFormatter() |
| 2839 | 2839 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsendable-true--1c3982c78639 / quicktype.swift+1 −1
| @@ -2544,7 +2544,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2544 | 2544 | let decoder = JSONDecoder() |
| 2545 | 2545 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2546 | 2546 | let container = try decoder.singleValueContainer() |
| 2547 | - let dateStr = try container.decode(String.self) | |
| 2547 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2548 | 2548 | |
| 2549 | 2549 | let formatter = DateFormatter() |
| 2550 | 2550 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftstruct-or-class-class--238d6c8a12d4 / quicktype.swift+1 −1
| @@ -2833,7 +2833,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2833 | 2833 | let decoder = JSONDecoder() |
| 2834 | 2834 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2835 | 2835 | let container = try decoder.singleValueContainer() |
| 2836 | - let dateStr = try container.decode(String.self) | |
| 2836 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2837 | 2837 | |
| 2838 | 2838 | let formatter = DateFormatter() |
| 2839 | 2839 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsupport-linux-false--4bd8c552e09a / quicktype.swift+7 −1
| @@ -2543,7 +2543,13 @@ enum Shakespearolater: Codable { | ||
| 2543 | 2543 | func newJSONDecoder() -> JSONDecoder { |
| 2544 | 2544 | let decoder = JSONDecoder() |
| 2545 | 2545 | if #available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *) { |
| 2546 | - decoder.dateDecodingStrategy = .iso8601 | |
| 2546 | + decoder.dateDecodingStrategy = .custom { decoder in | |
| 2547 | + let dateStr = try decoder.singleValueContainer().decode(String.self).uppercased() | |
| 2548 | + let dateData = try JSONEncoder().encode(dateStr) | |
| 2549 | + let dateDecoder = JSONDecoder() | |
| 2550 | + dateDecoder.dateDecodingStrategy = .iso8601 | |
| 2551 | + return try dateDecoder.decode(Date.self, from: dateData) | |
| 2552 | + } | |
| 2547 | 2553 | } |
| 2548 | 2554 | return decoder |
| 2549 | 2555 | } |
Test case
14 generated files · +20 −14test/inputs/json/priority/combinations3.json
Mswiftaccess-level-internal--a653a863c206 / quicktype.swift+1 −1
| @@ -3079,7 +3079,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3079 | 3079 | let decoder = JSONDecoder() |
| 3080 | 3080 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3081 | 3081 | let container = try decoder.singleValueContainer() |
| 3082 | - let dateStr = try container.decode(String.self) | |
| 3082 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3083 | 3083 | |
| 3084 | 3084 | let formatter = DateFormatter() |
| 3085 | 3085 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftaccess-level-public--bc6fc37ec004 / quicktype.swift+1 −1
| @@ -3461,7 +3461,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3461 | 3461 | let decoder = JSONDecoder() |
| 3462 | 3462 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3463 | 3463 | let container = try decoder.singleValueContainer() |
| 3464 | - let dateStr = try container.decode(String.self) | |
| 3464 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3465 | 3465 | |
| 3466 | 3466 | let formatter = DateFormatter() |
| 3467 | 3467 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftcoding-keys-false--33058e42a49b / quicktype.swift+1 −1
| @@ -3079,7 +3079,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3079 | 3079 | let decoder = JSONDecoder() |
| 3080 | 3080 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3081 | 3081 | let container = try decoder.singleValueContainer() |
| 3082 | - let dateStr = try container.decode(String.self) | |
| 3082 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3083 | 3083 | |
| 3084 | 3084 | let formatter = DateFormatter() |
| 3085 | 3085 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftcoding-keys-protocol-CaseIterable--169323764eaa / quicktype.swift+1 −1
| @@ -3079,7 +3079,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3079 | 3079 | let decoder = JSONDecoder() |
| 3080 | 3080 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3081 | 3081 | let container = try decoder.singleValueContainer() |
| 3082 | - let dateStr = try container.decode(String.self) | |
| 3082 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3083 | 3083 | |
| 3084 | 3084 | let formatter = DateFormatter() |
| 3085 | 3085 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftdefault / quicktype.swift+1 −1
| @@ -3079,7 +3079,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3079 | 3079 | let decoder = JSONDecoder() |
| 3080 | 3080 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3081 | 3081 | let container = try decoder.singleValueContainer() |
| 3082 | - let dateStr = try container.decode(String.self) | |
| 3082 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3083 | 3083 | |
| 3084 | 3084 | let formatter = DateFormatter() |
| 3085 | 3085 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftdensity-dense--3bfb4c22cfd0 / quicktype.swift+1 −1
| @@ -2626,7 +2626,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 2626 | 2626 | let decoder = JSONDecoder() |
| 2627 | 2627 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 2628 | 2628 | let container = try decoder.singleValueContainer() |
| 2629 | - let dateStr = try container.decode(String.self) | |
| 2629 | + let dateStr = try container.decode(String.self).uppercased() | |
| 2630 | 2630 | |
| 2631 | 2631 | let formatter = DateFormatter() |
| 2632 | 2632 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftfinal-classes-true__struct-or-class-class--d3c62ec7414d / quicktype.swift+1 −1
| @@ -3476,7 +3476,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3476 | 3476 | let decoder = JSONDecoder() |
| 3477 | 3477 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3478 | 3478 | let container = try decoder.singleValueContainer() |
| 3479 | - let dateStr = try container.decode(String.self) | |
| 3479 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3480 | 3480 | |
| 3481 | 3481 | let formatter = DateFormatter() |
| 3482 | 3482 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftmutable-properties-true--a9feb4120f94 / quicktype.swift+1 −1
| @@ -3079,7 +3079,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3079 | 3079 | let decoder = JSONDecoder() |
| 3080 | 3080 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3081 | 3081 | let container = try decoder.singleValueContainer() |
| 3082 | - let dateStr = try container.decode(String.self) | |
| 3082 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3083 | 3083 | |
| 3084 | 3084 | let formatter = DateFormatter() |
| 3085 | 3085 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftprotocol-equatable--bd9068f466c1 / quicktype.swift+1 −1
| @@ -3169,7 +3169,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3169 | 3169 | let decoder = JSONDecoder() |
| 3170 | 3170 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3171 | 3171 | let container = try decoder.singleValueContainer() |
| 3172 | - let dateStr = try container.decode(String.self) | |
| 3172 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3173 | 3173 | |
| 3174 | 3174 | let formatter = DateFormatter() |
| 3175 | 3175 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftprotocol-hashable--739b516c7897 / quicktype.swift+1 −1
| @@ -3169,7 +3169,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3169 | 3169 | let decoder = JSONDecoder() |
| 3170 | 3170 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3171 | 3171 | let container = try decoder.singleValueContainer() |
| 3172 | - let dateStr = try container.decode(String.self) | |
| 3172 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3173 | 3173 | |
| 3174 | 3174 | let formatter = DateFormatter() |
| 3175 | 3175 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsendable-true__struct-or-class-class--265b1fe2e96e / quicktype.swift+1 −1
| @@ -3476,7 +3476,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3476 | 3476 | let decoder = JSONDecoder() |
| 3477 | 3477 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3478 | 3478 | let container = try decoder.singleValueContainer() |
| 3479 | - let dateStr = try container.decode(String.self) | |
| 3479 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3480 | 3480 | |
| 3481 | 3481 | let formatter = DateFormatter() |
| 3482 | 3482 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsendable-true--1c3982c78639 / quicktype.swift+1 −1
| @@ -3079,7 +3079,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3079 | 3079 | let decoder = JSONDecoder() |
| 3080 | 3080 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3081 | 3081 | let container = try decoder.singleValueContainer() |
| 3082 | - let dateStr = try container.decode(String.self) | |
| 3082 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3083 | 3083 | |
| 3084 | 3084 | let formatter = DateFormatter() |
| 3085 | 3085 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftstruct-or-class-class--238d6c8a12d4 / quicktype.swift+1 −1
| @@ -3476,7 +3476,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3476 | 3476 | let decoder = JSONDecoder() |
| 3477 | 3477 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3478 | 3478 | let container = try decoder.singleValueContainer() |
| 3479 | - let dateStr = try container.decode(String.self) | |
| 3479 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3480 | 3480 | |
| 3481 | 3481 | let formatter = DateFormatter() |
| 3482 | 3482 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsupport-linux-false--4bd8c552e09a / quicktype.swift+7 −1
| @@ -3078,7 +3078,13 @@ enum Protext: Codable { | ||
| 3078 | 3078 | func newJSONDecoder() -> JSONDecoder { |
| 3079 | 3079 | let decoder = JSONDecoder() |
| 3080 | 3080 | if #available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *) { |
| 3081 | - decoder.dateDecodingStrategy = .iso8601 | |
| 3081 | + decoder.dateDecodingStrategy = .custom { decoder in | |
| 3082 | + let dateStr = try decoder.singleValueContainer().decode(String.self).uppercased() | |
| 3083 | + let dateData = try JSONEncoder().encode(dateStr) | |
| 3084 | + let dateDecoder = JSONDecoder() | |
| 3085 | + dateDecoder.dateDecodingStrategy = .iso8601 | |
| 3086 | + return try dateDecoder.decode(Date.self, from: dateData) | |
| 3087 | + } | |
| 3082 | 3088 | } |
| 3083 | 3089 | return decoder |
| 3084 | 3090 | } |
Test case
14 generated files · +20 −14test/inputs/json/priority/combinations4.json
Mswiftaccess-level-internal--a653a863c206 / quicktype.swift+1 −1
| @@ -3583,7 +3583,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3583 | 3583 | let decoder = JSONDecoder() |
| 3584 | 3584 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3585 | 3585 | let container = try decoder.singleValueContainer() |
| 3586 | - let dateStr = try container.decode(String.self) | |
| 3586 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3587 | 3587 | |
| 3588 | 3588 | let formatter = DateFormatter() |
| 3589 | 3589 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftaccess-level-public--bc6fc37ec004 / quicktype.swift+1 −1
| @@ -4021,7 +4021,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 4021 | 4021 | let decoder = JSONDecoder() |
| 4022 | 4022 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 4023 | 4023 | let container = try decoder.singleValueContainer() |
| 4024 | - let dateStr = try container.decode(String.self) | |
| 4024 | + let dateStr = try container.decode(String.self).uppercased() | |
| 4025 | 4025 | |
| 4026 | 4026 | let formatter = DateFormatter() |
| 4027 | 4027 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftcoding-keys-false--33058e42a49b / quicktype.swift+1 −1
| @@ -3583,7 +3583,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3583 | 3583 | let decoder = JSONDecoder() |
| 3584 | 3584 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3585 | 3585 | let container = try decoder.singleValueContainer() |
| 3586 | - let dateStr = try container.decode(String.self) | |
| 3586 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3587 | 3587 | |
| 3588 | 3588 | let formatter = DateFormatter() |
| 3589 | 3589 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftcoding-keys-protocol-CaseIterable--169323764eaa / quicktype.swift+1 −1
| @@ -3583,7 +3583,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3583 | 3583 | let decoder = JSONDecoder() |
| 3584 | 3584 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3585 | 3585 | let container = try decoder.singleValueContainer() |
| 3586 | - let dateStr = try container.decode(String.self) | |
| 3586 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3587 | 3587 | |
| 3588 | 3588 | let formatter = DateFormatter() |
| 3589 | 3589 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftdefault / quicktype.swift+1 −1
| @@ -3583,7 +3583,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3583 | 3583 | let decoder = JSONDecoder() |
| 3584 | 3584 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3585 | 3585 | let container = try decoder.singleValueContainer() |
| 3586 | - let dateStr = try container.decode(String.self) | |
| 3586 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3587 | 3587 | |
| 3588 | 3588 | let formatter = DateFormatter() |
| 3589 | 3589 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftdensity-dense--3bfb4c22cfd0 / quicktype.swift+1 −1
| @@ -3053,7 +3053,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3053 | 3053 | let decoder = JSONDecoder() |
| 3054 | 3054 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3055 | 3055 | let container = try decoder.singleValueContainer() |
| 3056 | - let dateStr = try container.decode(String.self) | |
| 3056 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3057 | 3057 | |
| 3058 | 3058 | let formatter = DateFormatter() |
| 3059 | 3059 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftfinal-classes-true__struct-or-class-class--d3c62ec7414d / quicktype.swift+1 −1
| @@ -4038,7 +4038,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 4038 | 4038 | let decoder = JSONDecoder() |
| 4039 | 4039 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 4040 | 4040 | let container = try decoder.singleValueContainer() |
| 4041 | - let dateStr = try container.decode(String.self) | |
| 4041 | + let dateStr = try container.decode(String.self).uppercased() | |
| 4042 | 4042 | |
| 4043 | 4043 | let formatter = DateFormatter() |
| 4044 | 4044 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftmutable-properties-true--a9feb4120f94 / quicktype.swift+1 −1
| @@ -3583,7 +3583,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3583 | 3583 | let decoder = JSONDecoder() |
| 3584 | 3584 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3585 | 3585 | let container = try decoder.singleValueContainer() |
| 3586 | - let dateStr = try container.decode(String.self) | |
| 3586 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3587 | 3587 | |
| 3588 | 3588 | let formatter = DateFormatter() |
| 3589 | 3589 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftprotocol-equatable--bd9068f466c1 / quicktype.swift+1 −1
| @@ -3685,7 +3685,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3685 | 3685 | let decoder = JSONDecoder() |
| 3686 | 3686 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3687 | 3687 | let container = try decoder.singleValueContainer() |
| 3688 | - let dateStr = try container.decode(String.self) | |
| 3688 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3689 | 3689 | |
| 3690 | 3690 | let formatter = DateFormatter() |
| 3691 | 3691 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftprotocol-hashable--739b516c7897 / quicktype.swift+1 −1
| @@ -3685,7 +3685,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3685 | 3685 | let decoder = JSONDecoder() |
| 3686 | 3686 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3687 | 3687 | let container = try decoder.singleValueContainer() |
| 3688 | - let dateStr = try container.decode(String.self) | |
| 3688 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3689 | 3689 | |
| 3690 | 3690 | let formatter = DateFormatter() |
| 3691 | 3691 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsendable-true__struct-or-class-class--265b1fe2e96e / quicktype.swift+1 −1
| @@ -4038,7 +4038,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 4038 | 4038 | let decoder = JSONDecoder() |
| 4039 | 4039 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 4040 | 4040 | let container = try decoder.singleValueContainer() |
| 4041 | - let dateStr = try container.decode(String.self) | |
| 4041 | + let dateStr = try container.decode(String.self).uppercased() | |
| 4042 | 4042 | |
| 4043 | 4043 | let formatter = DateFormatter() |
| 4044 | 4044 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsendable-true--1c3982c78639 / quicktype.swift+1 −1
| @@ -3583,7 +3583,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 3583 | 3583 | let decoder = JSONDecoder() |
| 3584 | 3584 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 3585 | 3585 | let container = try decoder.singleValueContainer() |
| 3586 | - let dateStr = try container.decode(String.self) | |
| 3586 | + let dateStr = try container.decode(String.self).uppercased() | |
| 3587 | 3587 | |
| 3588 | 3588 | let formatter = DateFormatter() |
| 3589 | 3589 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftstruct-or-class-class--238d6c8a12d4 / quicktype.swift+1 −1
| @@ -4038,7 +4038,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 4038 | 4038 | let decoder = JSONDecoder() |
| 4039 | 4039 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 4040 | 4040 | let container = try decoder.singleValueContainer() |
| 4041 | - let dateStr = try container.decode(String.self) | |
| 4041 | + let dateStr = try container.decode(String.self).uppercased() | |
| 4042 | 4042 | |
| 4043 | 4043 | let formatter = DateFormatter() |
| 4044 | 4044 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsupport-linux-false--4bd8c552e09a / quicktype.swift+7 −1
| @@ -3582,7 +3582,13 @@ extension WrothyClass { | ||
| 3582 | 3582 | func newJSONDecoder() -> JSONDecoder { |
| 3583 | 3583 | let decoder = JSONDecoder() |
| 3584 | 3584 | if #available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *) { |
| 3585 | - decoder.dateDecodingStrategy = .iso8601 | |
| 3585 | + decoder.dateDecodingStrategy = .custom { decoder in | |
| 3586 | + let dateStr = try decoder.singleValueContainer().decode(String.self).uppercased() | |
| 3587 | + let dateData = try JSONEncoder().encode(dateStr) | |
| 3588 | + let dateDecoder = JSONDecoder() | |
| 3589 | + dateDecoder.dateDecodingStrategy = .iso8601 | |
| 3590 | + return try dateDecoder.decode(Date.self, from: dateData) | |
| 3591 | + } | |
| 3586 | 3592 | } |
| 3587 | 3593 | return decoder |
| 3588 | 3594 | } |
Test case
1 generated file · +1 −1test/inputs/json/priority/combined-enum.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -109,7 +109,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 109 | 109 | let decoder = JSONDecoder() |
| 110 | 110 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 111 | 111 | let container = try decoder.singleValueContainer() |
| 112 | - let dateStr = try container.decode(String.self) | |
| 112 | + let dateStr = try container.decode(String.self).uppercased() | |
| 113 | 113 | |
| 114 | 114 | let formatter = DateFormatter() |
| 115 | 115 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/direct-recursive.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -80,7 +80,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 80 | 80 | let decoder = JSONDecoder() |
| 81 | 81 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 82 | 82 | let container = try decoder.singleValueContainer() |
| 83 | - let dateStr = try container.decode(String.self) | |
| 83 | + let dateStr = try container.decode(String.self).uppercased() | |
| 84 | 84 | |
| 85 | 85 | let formatter = DateFormatter() |
| 86 | 86 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/empty-enum.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -99,7 +99,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 99 | 99 | let decoder = JSONDecoder() |
| 100 | 100 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 101 | 101 | let container = try decoder.singleValueContainer() |
| 102 | - let dateStr = try container.decode(String.self) | |
| 102 | + let dateStr = try container.decode(String.self).uppercased() | |
| 103 | 103 | |
| 104 | 104 | let formatter = DateFormatter() |
| 105 | 105 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/identifiers.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -350,7 +350,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 350 | 350 | let decoder = JSONDecoder() |
| 351 | 351 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 352 | 352 | let container = try decoder.singleValueContainer() |
| 353 | - let dateStr = try container.decode(String.self) | |
| 353 | + let dateStr = try container.decode(String.self).uppercased() | |
| 354 | 354 | |
| 355 | 355 | let formatter = DateFormatter() |
| 356 | 356 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/issue2680-object-array.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -82,7 +82,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 82 | 82 | let decoder = JSONDecoder() |
| 83 | 83 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 84 | 84 | let container = try decoder.singleValueContainer() |
| 85 | - let dateStr = try container.decode(String.self) | |
| 85 | + let dateStr = try container.decode(String.self).uppercased() | |
| 86 | 86 | |
| 87 | 87 | let formatter = DateFormatter() |
| 88 | 88 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/issue2680-scalar-array.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -37,7 +37,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 37 | 37 | let decoder = JSONDecoder() |
| 38 | 38 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 39 | 39 | let container = try decoder.singleValueContainer() |
| 40 | - let dateStr = try container.decode(String.self) | |
| 40 | + let dateStr = try container.decode(String.self).uppercased() | |
| 41 | 41 | |
| 42 | 42 | let formatter = DateFormatter() |
| 43 | 43 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
7 generated files · +11 −6test/inputs/json/priority/keywords.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -8952,7 +8952,7 @@ namespace quicktype { | ||
| 8952 | 8952 | |
| 8953 | 8953 | inline void from_json(const json & j, DateTime& x) { |
| 8954 | 8954 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 8955 | - if (j.find("DateTime") != j.end() && !std::regex_match(j.at("DateTime").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 8955 | + if (j.find("DateTime") != j.end() && !std::regex_match(j.at("DateTime").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 8956 | 8956 | x.set_date_time(j.at("DateTime").get<std::string>()); |
| 8957 | 8957 | } |
Mobjective-cdefault / QTTopLevel.m+2 −1
| @@ -6077,7 +6077,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 6077 | 6077 | - (instancetype)initWithJSONDictionary:(NSDictionary *)dict |
| 6078 | 6078 | { |
| 6079 | 6079 | if (self = [super init]) { |
| 6080 | - if (dict[@"DateTime"] && [dict[@"DateTime"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 6080 | + if (dict[@"DateTime"] && [dict[@"DateTime"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 6081 | + if (dict[@"DateTime"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"DateTime"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"DateTime"] substringToIndex:10]]) return nil; | |
| 6081 | 6082 | if (![dict[@"DateTime"] isKindOfClass:NSString.class]) return nil; |
| 6082 | 6083 | [self setValuesForKeysWithDictionary:dict]; |
| 6083 | 6084 | } |
Mphpdefault / TopLevel.php+4 −0
| @@ -15165,6 +15165,10 @@ class DateTimeClass { | ||
| 15165 | 15165 | */ |
| 15166 | 15166 | public static function fromDateTime(string $value): DateTime { |
| 15167 | 15167 | $tmp = new DateTime($value); |
| 15168 | + $errors = DateTime::getLastErrors(); | |
| 15169 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 15170 | + throw new Exception('Invalid date-time'); | |
| 15171 | + } | |
| 15168 | 15172 | if (!is_a($tmp, 'DateTime')) { |
| 15169 | 15173 | throw new Exception('Attribute Error:DateTimeClass::'); |
| 15170 | 15174 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -17484,7 +17484,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 17484 | 17484 | let decoder = JSONDecoder() |
| 17485 | 17485 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 17486 | 17486 | let container = try decoder.singleValueContainer() |
| 17487 | - let dateStr = try container.decode(String.self) | |
| 17487 | + let dateStr = try container.decode(String.self).uppercased() | |
| 17488 | 17488 | |
| 17489 | 17489 | let formatter = DateFormatter() |
| 17490 | 17490 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftobjective-c-support-true__struct-or-class-class--f14372afa3e4 / quicktype.swift+1 −1
| @@ -19667,7 +19667,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 19667 | 19667 | let decoder = JSONDecoder() |
| 19668 | 19668 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 19669 | 19669 | let container = try decoder.singleValueContainer() |
| 19670 | - let dateStr = try container.decode(String.self) | |
| 19670 | + let dateStr = try container.decode(String.self).uppercased() | |
| 19671 | 19671 | |
| 19672 | 19672 | let formatter = DateFormatter() |
| 19673 | 19673 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftprotocol-equatable--bd9068f466c1 / quicktype.swift+1 −1
| @@ -19668,7 +19668,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 19668 | 19668 | let decoder = JSONDecoder() |
| 19669 | 19669 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 19670 | 19670 | let container = try decoder.singleValueContainer() |
| 19671 | - let dateStr = try container.decode(String.self) | |
| 19671 | + let dateStr = try container.decode(String.self).uppercased() | |
| 19672 | 19672 | |
| 19673 | 19673 | let formatter = DateFormatter() |
| 19674 | 19674 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftsendable-true--1c3982c78639 / quicktype.swift+1 −1
| @@ -17484,7 +17484,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 17484 | 17484 | let decoder = JSONDecoder() |
| 17485 | 17485 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 17486 | 17486 | let container = try decoder.singleValueContainer() |
| 17487 | - let dateStr = try container.decode(String.self) | |
| 17487 | + let dateStr = try container.decode(String.self).uppercased() | |
| 17488 | 17488 | |
| 17489 | 17489 | let formatter = DateFormatter() |
| 17490 | 17490 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/kotlin-enum-class-case-collision.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -87,7 +87,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 87 | 87 | let decoder = JSONDecoder() |
| 88 | 88 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 89 | 89 | let container = try decoder.singleValueContainer() |
| 90 | - let dateStr = try container.decode(String.self) | |
| 90 | + let dateStr = try container.decode(String.self).uppercased() | |
| 91 | 91 | |
| 92 | 92 | let formatter = DateFormatter() |
| 93 | 93 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/list.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -65,7 +65,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 65 | 65 | let decoder = JSONDecoder() |
| 66 | 66 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 67 | 67 | let container = try decoder.singleValueContainer() |
| 68 | - let dateStr = try container.decode(String.self) | |
| 68 | + let dateStr = try container.decode(String.self).uppercased() | |
| 69 | 69 | |
| 70 | 70 | let formatter = DateFormatter() |
| 71 | 71 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/name-style.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -79,7 +79,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 79 | 79 | let decoder = JSONDecoder() |
| 80 | 80 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 81 | 81 | let container = try decoder.singleValueContainer() |
| 82 | - let dateStr = try container.decode(String.self) | |
| 82 | + let dateStr = try container.decode(String.self).uppercased() | |
| 83 | 83 | |
| 84 | 84 | let formatter = DateFormatter() |
| 85 | 85 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/nbl-stats.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -1559,7 +1559,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 1559 | 1559 | let decoder = JSONDecoder() |
| 1560 | 1560 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 1561 | 1561 | let container = try decoder.singleValueContainer() |
| 1562 | - let dateStr = try container.decode(String.self) | |
| 1562 | + let dateStr = try container.decode(String.self).uppercased() | |
| 1563 | 1563 | |
| 1564 | 1564 | let formatter = DateFormatter() |
| 1565 | 1565 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/nested-objects.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -59,7 +59,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 59 | 59 | let decoder = JSONDecoder() |
| 60 | 60 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 61 | 61 | let container = try decoder.singleValueContainer() |
| 62 | - let dateStr = try container.decode(String.self) | |
| 62 | + let dateStr = try container.decode(String.self).uppercased() | |
| 63 | 63 | |
| 64 | 64 | let formatter = DateFormatter() |
| 65 | 65 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/no-classes.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -12,7 +12,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 12 | 12 | let decoder = JSONDecoder() |
| 13 | 13 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 14 | 14 | let container = try decoder.singleValueContainer() |
| 15 | - let dateStr = try container.decode(String.self) | |
| 15 | + let dateStr = try container.decode(String.self).uppercased() | |
| 16 | 16 | |
| 17 | 17 | let formatter = DateFormatter() |
| 18 | 18 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/number-map.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/omit-empty.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/optional-union.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -110,7 +110,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 110 | 110 | let decoder = JSONDecoder() |
| 111 | 111 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 112 | 112 | let container = try decoder.singleValueContainer() |
| 113 | - let dateStr = try container.decode(String.self) | |
| 113 | + let dateStr = try container.decode(String.self).uppercased() | |
| 114 | 114 | |
| 115 | 115 | let formatter = DateFormatter() |
| 116 | 116 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/php-mixed-union.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -148,7 +148,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 148 | 148 | let decoder = JSONDecoder() |
| 149 | 149 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 150 | 150 | let container = try decoder.singleValueContainer() |
| 151 | - let dateStr = try container.decode(String.self) | |
| 151 | + let dateStr = try container.decode(String.self).uppercased() | |
| 152 | 152 | |
| 153 | 153 | let formatter = DateFormatter() |
| 154 | 154 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/php-validation.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -71,7 +71,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 71 | 71 | let decoder = JSONDecoder() |
| 72 | 72 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 73 | 73 | let container = try decoder.singleValueContainer() |
| 74 | - let dateStr = try container.decode(String.self) | |
| 74 | + let dateStr = try container.decode(String.self).uppercased() | |
| 75 | 75 | |
| 76 | 76 | let formatter = DateFormatter() |
| 77 | 77 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/recursive.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -979,7 +979,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 979 | 979 | let decoder = JSONDecoder() |
| 980 | 980 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 981 | 981 | let container = try decoder.singleValueContainer() |
| 982 | - let dateStr = try container.decode(String.self) | |
| 982 | + let dateStr = try container.decode(String.self).uppercased() | |
| 983 | 983 | |
| 984 | 984 | let formatter = DateFormatter() |
| 985 | 985 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/simple-identifiers.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -87,7 +87,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 87 | 87 | let decoder = JSONDecoder() |
| 88 | 88 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 89 | 89 | let container = try decoder.singleValueContainer() |
| 90 | - let dateStr = try container.decode(String.self) | |
| 90 | + let dateStr = try container.decode(String.self).uppercased() | |
| 91 | 91 | |
| 92 | 92 | let formatter = DateFormatter() |
| 93 | 93 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/union-constructor-clash.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -131,7 +131,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 131 | 131 | let decoder = JSONDecoder() |
| 132 | 132 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 133 | 133 | let container = try decoder.singleValueContainer() |
| 134 | - let dateStr = try container.decode(String.self) | |
| 134 | + let dateStr = try container.decode(String.self).uppercased() | |
| 135 | 135 | |
| 136 | 136 | let formatter = DateFormatter() |
| 137 | 137 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/unions.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -177,7 +177,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 177 | 177 | let decoder = JSONDecoder() |
| 178 | 178 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 179 | 179 | let container = try decoder.singleValueContainer() |
| 180 | - let dateStr = try container.decode(String.self) | |
| 180 | + let dateStr = try container.decode(String.self).uppercased() | |
| 181 | 181 | |
| 182 | 182 | let formatter = DateFormatter() |
| 183 | 183 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/url.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -59,7 +59,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 59 | 59 | let decoder = JSONDecoder() |
| 60 | 60 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 61 | 61 | let container = try decoder.singleValueContainer() |
| 62 | - let dateStr = try container.decode(String.self) | |
| 62 | + let dateStr = try container.decode(String.self).uppercased() | |
| 63 | 63 | |
| 64 | 64 | let formatter = DateFormatter() |
| 65 | 65 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/priority/uuids.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -75,7 +75,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 75 | 75 | let decoder = JSONDecoder() |
| 76 | 76 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 77 | 77 | let container = try decoder.singleValueContainer() |
| 78 | - let dateStr = try container.decode(String.self) | |
| 78 | + let dateStr = try container.decode(String.self).uppercased() | |
| 79 | 79 | |
| 80 | 80 | let formatter = DateFormatter() |
| 81 | 81 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/samples/bitcoin-block.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -71,7 +71,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 71 | 71 | let decoder = JSONDecoder() |
| 72 | 72 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 73 | 73 | let container = try decoder.singleValueContainer() |
| 74 | - let dateStr = try container.decode(String.self) | |
| 74 | + let dateStr = try container.decode(String.self).uppercased() | |
| 75 | 75 | |
| 76 | 76 | let formatter = DateFormatter() |
| 77 | 77 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/samples/copy-with-property.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -59,7 +59,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 59 | 59 | let decoder = JSONDecoder() |
| 60 | 60 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 61 | 61 | let container = try decoder.singleValueContainer() |
| 62 | - let dateStr = try container.decode(String.self) | |
| 62 | + let dateStr = try container.decode(String.self).uppercased() | |
| 63 | 63 | |
| 64 | 64 | let formatter = DateFormatter() |
| 65 | 65 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/samples/getting-started.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -59,7 +59,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 59 | 59 | let decoder = JSONDecoder() |
| 60 | 60 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 61 | 61 | let container = try decoder.singleValueContainer() |
| 62 | - let dateStr = try container.decode(String.self) | |
| 62 | + let dateStr = try container.decode(String.self).uppercased() | |
| 63 | 63 | |
| 64 | 64 | let formatter = DateFormatter() |
| 65 | 65 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +107 −29test/inputs/json/samples/github-events.json
Mcplusplusdefault / quicktype.hpp+14 −14
| @@ -1541,13 +1541,13 @@ namespace quicktype { | ||
| 1541 | 1541 | inline void from_json(const json & j, Comment& x) { |
| 1542 | 1542 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 1543 | 1543 | x.set_body(j.at("body").get<std::string>()); |
| 1544 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1544 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1545 | 1545 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 1546 | 1546 | x.set_html_url(j.at("html_url").get<std::string>()); |
| 1547 | 1547 | if (j.find("id") != j.end() && !j.at("id").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 1548 | 1548 | x.set_id(j.at("id").get<int64_t>()); |
| 1549 | 1549 | x.set_issue_url(j.at("issue_url").get<std::string>()); |
| 1550 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1550 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1551 | 1551 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 1552 | 1552 | x.set_url(j.at("url").get<std::string>()); |
| 1553 | 1553 | x.set_user(j.at("user").get<User>()); |
| @@ -1619,7 +1619,7 @@ namespace quicktype { | ||
| 1619 | 1619 | x.set_closed_at(get_untyped(j, "closed_at")); |
| 1620 | 1620 | if (j.find("closed_issues") != j.end() && !j.at("closed_issues").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 1621 | 1621 | x.set_closed_issues(j.at("closed_issues").get<int64_t>()); |
| 1622 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1622 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1623 | 1623 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 1624 | 1624 | x.set_creator(j.at("creator").get<User>()); |
| 1625 | 1625 | x.set_description(j.at("description").get<std::string>()); |
| @@ -1635,7 +1635,7 @@ namespace quicktype { | ||
| 1635 | 1635 | x.set_open_issues(j.at("open_issues").get<int64_t>()); |
| 1636 | 1636 | x.set_state(j.at("state").get<std::string>()); |
| 1637 | 1637 | x.set_title(j.at("title").get<std::string>()); |
| 1638 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1638 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1639 | 1639 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 1640 | 1640 | x.set_url(j.at("url").get<std::string>()); |
| 1641 | 1641 | } |
| @@ -1685,7 +1685,7 @@ namespace quicktype { | ||
| 1685 | 1685 | if (j.find("comments") != j.end() && !j.at("comments").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 1686 | 1686 | x.set_comments(j.at("comments").get<int64_t>()); |
| 1687 | 1687 | x.set_comments_url(j.at("comments_url").get<std::string>()); |
| 1688 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1688 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1689 | 1689 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 1690 | 1690 | x.set_events_url(j.at("events_url").get<std::string>()); |
| 1691 | 1691 | x.set_html_url(j.at("html_url").get<std::string>()); |
| @@ -1703,7 +1703,7 @@ namespace quicktype { | ||
| 1703 | 1703 | x.set_repository_url(j.at("repository_url").get<std::string>()); |
| 1704 | 1704 | x.set_state(j.at("state").get<std::string>()); |
| 1705 | 1705 | x.set_title(j.at("title").get<std::string>()); |
| 1706 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1706 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1707 | 1707 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 1708 | 1708 | x.set_url(j.at("url").get<std::string>()); |
| 1709 | 1709 | x.set_user(j.at("user").get<User>()); |
| @@ -1748,7 +1748,7 @@ namespace quicktype { | ||
| 1748 | 1748 | x.set_compare_url(j.at("compare_url").get<std::string>()); |
| 1749 | 1749 | x.set_contents_url(j.at("contents_url").get<std::string>()); |
| 1750 | 1750 | x.set_contributors_url(j.at("contributors_url").get<std::string>()); |
| 1751 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1751 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1752 | 1752 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 1753 | 1753 | x.set_default_branch(j.at("default_branch").get<std::string>()); |
| 1754 | 1754 | x.set_deployments_url(j.at("deployments_url").get<std::string>()); |
| @@ -1794,7 +1794,7 @@ namespace quicktype { | ||
| 1794 | 1794 | x.set_open_issues_count(j.at("open_issues_count").get<int64_t>()); |
| 1795 | 1795 | x.set_owner(j.at("owner").get<User>()); |
| 1796 | 1796 | x.set_pulls_url(j.at("pulls_url").get<std::string>()); |
| 1797 | - if (j.find("pushed_at") != j.end() && !std::regex_match(j.at("pushed_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1797 | + if (j.find("pushed_at") != j.end() && !std::regex_match(j.at("pushed_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1798 | 1798 | x.set_pushed_at(j.at("pushed_at").get<std::string>()); |
| 1799 | 1799 | x.set_releases_url(j.at("releases_url").get<std::string>()); |
| 1800 | 1800 | x.set_repo_private(j.at("private").get<bool>()); |
| @@ -1811,7 +1811,7 @@ namespace quicktype { | ||
| 1811 | 1811 | x.set_tags_url(j.at("tags_url").get<std::string>()); |
| 1812 | 1812 | x.set_teams_url(j.at("teams_url").get<std::string>()); |
| 1813 | 1813 | x.set_trees_url(j.at("trees_url").get<std::string>()); |
| 1814 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1814 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1815 | 1815 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 1816 | 1816 | x.set_url(j.at("url").get<std::string>()); |
| 1817 | 1817 | if (j.find("watchers") != j.end() && !j.at("watchers").is_number_integer()) throw std::runtime_error("Expected integer"); |
| @@ -1955,7 +1955,7 @@ namespace quicktype { | ||
| 1955 | 1955 | x.set_body(j.at("body").get<std::string>()); |
| 1956 | 1956 | if (j.find("changed_files") != j.end() && !j.at("changed_files").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 1957 | 1957 | x.set_changed_files(j.at("changed_files").get<int64_t>()); |
| 1958 | - if (j.find("closed_at") != j.end() && !std::regex_match(j.at("closed_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1958 | + if (j.find("closed_at") != j.end() && !std::regex_match(j.at("closed_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1959 | 1959 | x.set_closed_at(j.at("closed_at").get<std::string>()); |
| 1960 | 1960 | if (j.find("comments") != j.end() && !j.at("comments").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 1961 | 1961 | x.set_comments(j.at("comments").get<int64_t>()); |
| @@ -1963,7 +1963,7 @@ namespace quicktype { | ||
| 1963 | 1963 | if (j.find("commits") != j.end() && !j.at("commits").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 1964 | 1964 | x.set_commits(j.at("commits").get<int64_t>()); |
| 1965 | 1965 | x.set_commits_url(j.at("commits_url").get<std::string>()); |
| 1966 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1966 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1967 | 1967 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 1968 | 1968 | if (j.find("deletions") != j.end() && !j.at("deletions").is_number_integer()) throw std::runtime_error("Expected integer"); |
| 1969 | 1969 | x.set_deletions(j.at("deletions").get<int64_t>()); |
| @@ -1980,7 +1980,7 @@ namespace quicktype { | ||
| 1980 | 1980 | x.set_mergeable(get_untyped(j, "mergeable")); |
| 1981 | 1981 | x.set_mergeable_state(j.at("mergeable_state").get<std::string>()); |
| 1982 | 1982 | x.set_merged(j.at("merged").get<bool>()); |
| 1983 | - if (j.find("merged_at") != j.end() && !std::regex_match(j.at("merged_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1983 | + if (j.find("merged_at") != j.end() && !std::regex_match(j.at("merged_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 1984 | 1984 | x.set_merged_at(j.at("merged_at").get<std::string>()); |
| 1985 | 1985 | x.set_merged_by(j.at("merged_by").get<User>()); |
| 1986 | 1986 | x.set_milestone(get_untyped(j, "milestone")); |
| @@ -1996,7 +1996,7 @@ namespace quicktype { | ||
| 1996 | 1996 | x.set_state(j.at("state").get<std::string>()); |
| 1997 | 1997 | x.set_statuses_url(j.at("statuses_url").get<std::string>()); |
| 1998 | 1998 | x.set_title(j.at("title").get<std::string>()); |
| 1999 | - if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 1999 | + if (j.find("updated_at") != j.end() && !std::regex_match(j.at("updated_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 2000 | 2000 | x.set_updated_at(j.at("updated_at").get<std::string>()); |
| 2001 | 2001 | x.set_url(j.at("url").get<std::string>()); |
| 2002 | 2002 | x.set_user(j.at("user").get<User>()); |
| @@ -2125,7 +2125,7 @@ namespace quicktype { | ||
| 2125 | 2125 | inline void from_json(const json & j, TopLevelElement& x) { |
| 2126 | 2126 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 2127 | 2127 | x.set_actor(j.at("actor").get<Actor>()); |
| 2128 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 2128 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 2129 | 2129 | x.set_created_at(j.at("created_at").get<std::string>()); |
| 2130 | 2130 | x.set_id(j.at("id").get<std::string>()); |
| 2131 | 2131 | if (j.find("org") != j.end() && j.at("org").is_null()) throw std::runtime_error("Unexpected null"); |
Mobjective-cdefault / QTTopLevel.m+28 −14
| @@ -194,7 +194,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 194 | 194 | { |
| 195 | 195 | if (self = [super init]) { |
| 196 | 196 | if (![dict[@"actor"] isKindOfClass:NSDictionary.class]) return nil; |
| 197 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 197 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 198 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 198 | 199 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 199 | 200 | if (![dict[@"id"] isKindOfClass:NSString.class]) return nil; |
| 200 | 201 | if (![dict[@"public"] isKindOfClass:NSNumber.class]) return nil; |
| @@ -415,13 +416,15 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 415 | 416 | { |
| 416 | 417 | if (self = [super init]) { |
| 417 | 418 | if (![dict[@"body"] isKindOfClass:NSString.class]) return nil; |
| 418 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 419 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 420 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 419 | 421 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 420 | 422 | if (![dict[@"html_url"] isKindOfClass:NSString.class]) return nil; |
| 421 | 423 | if (![dict[@"id"] isKindOfClass:NSNumber.class]) return nil; |
| 422 | 424 | if ([dict[@"id"] doubleValue] != [dict[@"id"] longLongValue]) return nil; |
| 423 | 425 | if (![dict[@"issue_url"] isKindOfClass:NSString.class]) return nil; |
| 424 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 426 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 427 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 425 | 428 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 426 | 429 | if (![dict[@"url"] isKindOfClass:NSString.class]) return nil; |
| 427 | 430 | if (![dict[@"user"] isKindOfClass:NSDictionary.class]) return nil; |
| @@ -708,7 +711,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 708 | 711 | if (![dict[@"comments"] isKindOfClass:NSNumber.class]) return nil; |
| 709 | 712 | if ([dict[@"comments"] doubleValue] != [dict[@"comments"] longLongValue]) return nil; |
| 710 | 713 | if (![dict[@"comments_url"] isKindOfClass:NSString.class]) return nil; |
| 711 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 714 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 715 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 712 | 716 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 713 | 717 | if (![dict[@"events_url"] isKindOfClass:NSString.class]) return nil; |
| 714 | 718 | if (![dict[@"html_url"] isKindOfClass:NSString.class]) return nil; |
| @@ -723,7 +727,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 723 | 727 | if (![dict[@"repository_url"] isKindOfClass:NSString.class]) return nil; |
| 724 | 728 | if (![dict[@"state"] isKindOfClass:NSString.class]) return nil; |
| 725 | 729 | if (![dict[@"title"] isKindOfClass:NSString.class]) return nil; |
| 726 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 730 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 731 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 727 | 732 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 728 | 733 | if (![dict[@"url"] isKindOfClass:NSString.class]) return nil; |
| 729 | 734 | if (![dict[@"user"] isKindOfClass:NSDictionary.class]) return nil; |
| @@ -873,7 +878,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 873 | 878 | if (!dict[@"closed_at"]) return nil; |
| 874 | 879 | if (![dict[@"closed_issues"] isKindOfClass:NSNumber.class]) return nil; |
| 875 | 880 | if ([dict[@"closed_issues"] doubleValue] != [dict[@"closed_issues"] longLongValue]) return nil; |
| 876 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 881 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 882 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 877 | 883 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 878 | 884 | if (![dict[@"creator"] isKindOfClass:NSDictionary.class]) return nil; |
| 879 | 885 | if (!dict[@"due_on"]) return nil; |
| @@ -888,7 +894,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 888 | 894 | if (![dict[@"state"] isKindOfClass:NSString.class]) return nil; |
| 889 | 895 | if (![dict[@"description"] isKindOfClass:NSString.class]) return nil; |
| 890 | 896 | if (![dict[@"title"] isKindOfClass:NSString.class]) return nil; |
| 891 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 897 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 898 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 892 | 899 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 893 | 900 | if (![dict[@"url"] isKindOfClass:NSString.class]) return nil; |
| 894 | 901 | [self setValuesForKeysWithDictionary:dict]; |
| @@ -1052,7 +1059,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 1052 | 1059 | if (![dict[@"body"] isKindOfClass:NSString.class]) return nil; |
| 1053 | 1060 | if (![dict[@"changed_files"] isKindOfClass:NSNumber.class]) return nil; |
| 1054 | 1061 | if ([dict[@"changed_files"] doubleValue] != [dict[@"changed_files"] longLongValue]) return nil; |
| 1055 | - if (dict[@"closed_at"] && [dict[@"closed_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1062 | + if (dict[@"closed_at"] && [dict[@"closed_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1063 | + if (dict[@"closed_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"closed_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"closed_at"] substringToIndex:10]]) return nil; | |
| 1056 | 1064 | if (![dict[@"closed_at"] isKindOfClass:NSString.class]) return nil; |
| 1057 | 1065 | if (![dict[@"comments"] isKindOfClass:NSNumber.class]) return nil; |
| 1058 | 1066 | if ([dict[@"comments"] doubleValue] != [dict[@"comments"] longLongValue]) return nil; |
| @@ -1060,7 +1068,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 1060 | 1068 | if (![dict[@"commits"] isKindOfClass:NSNumber.class]) return nil; |
| 1061 | 1069 | if ([dict[@"commits"] doubleValue] != [dict[@"commits"] longLongValue]) return nil; |
| 1062 | 1070 | if (![dict[@"commits_url"] isKindOfClass:NSString.class]) return nil; |
| 1063 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1071 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1072 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 1064 | 1073 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 1065 | 1074 | if (![dict[@"deletions"] isKindOfClass:NSNumber.class]) return nil; |
| 1066 | 1075 | if ([dict[@"deletions"] doubleValue] != [dict[@"deletions"] longLongValue]) return nil; |
| @@ -1077,7 +1086,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 1077 | 1086 | if (![dict[@"merge_commit_sha"] isKindOfClass:NSString.class]) return nil; |
| 1078 | 1087 | if (!dict[@"mergeable"]) return nil; |
| 1079 | 1088 | if (![dict[@"mergeable_state"] isKindOfClass:NSString.class]) return nil; |
| 1080 | - if (dict[@"merged_at"] && [dict[@"merged_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1089 | + if (dict[@"merged_at"] && [dict[@"merged_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1090 | + if (dict[@"merged_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"merged_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"merged_at"] substringToIndex:10]]) return nil; | |
| 1081 | 1091 | if (![dict[@"merged_at"] isKindOfClass:NSString.class]) return nil; |
| 1082 | 1092 | if (![dict[@"merged_by"] isKindOfClass:NSDictionary.class]) return nil; |
| 1083 | 1093 | if (!dict[@"milestone"]) return nil; |
| @@ -1093,7 +1103,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 1093 | 1103 | if (![dict[@"state"] isKindOfClass:NSString.class]) return nil; |
| 1094 | 1104 | if (![dict[@"statuses_url"] isKindOfClass:NSString.class]) return nil; |
| 1095 | 1105 | if (![dict[@"title"] isKindOfClass:NSString.class]) return nil; |
| 1096 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1106 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1107 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 1097 | 1108 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 1098 | 1109 | if (![dict[@"url"] isKindOfClass:NSString.class]) return nil; |
| 1099 | 1110 | if (![dict[@"user"] isKindOfClass:NSDictionary.class]) return nil; |
| @@ -1307,7 +1318,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 1307 | 1318 | if (![dict[@"compare_url"] isKindOfClass:NSString.class]) return nil; |
| 1308 | 1319 | if (![dict[@"contents_url"] isKindOfClass:NSString.class]) return nil; |
| 1309 | 1320 | if (![dict[@"contributors_url"] isKindOfClass:NSString.class]) return nil; |
| 1310 | - if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1321 | + if (dict[@"created_at"] && [dict[@"created_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1322 | + if (dict[@"created_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"created_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"created_at"] substringToIndex:10]]) return nil; | |
| 1311 | 1323 | if (![dict[@"created_at"] isKindOfClass:NSString.class]) return nil; |
| 1312 | 1324 | if (![dict[@"default_branch"] isKindOfClass:NSString.class]) return nil; |
| 1313 | 1325 | if (![dict[@"deployments_url"] isKindOfClass:NSString.class]) return nil; |
| @@ -1353,7 +1365,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 1353 | 1365 | if ([dict[@"open_issues_count"] doubleValue] != [dict[@"open_issues_count"] longLongValue]) return nil; |
| 1354 | 1366 | if (![dict[@"owner"] isKindOfClass:NSDictionary.class]) return nil; |
| 1355 | 1367 | if (![dict[@"pulls_url"] isKindOfClass:NSString.class]) return nil; |
| 1356 | - if (dict[@"pushed_at"] && [dict[@"pushed_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1368 | + if (dict[@"pushed_at"] && [dict[@"pushed_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1369 | + if (dict[@"pushed_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"pushed_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"pushed_at"] substringToIndex:10]]) return nil; | |
| 1357 | 1370 | if (![dict[@"pushed_at"] isKindOfClass:NSString.class]) return nil; |
| 1358 | 1371 | if (![dict[@"releases_url"] isKindOfClass:NSString.class]) return nil; |
| 1359 | 1372 | if (![dict[@"size"] isKindOfClass:NSNumber.class]) return nil; |
| @@ -1370,7 +1383,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 1370 | 1383 | if (![dict[@"teams_url"] isKindOfClass:NSString.class]) return nil; |
| 1371 | 1384 | if (![dict[@"description"] isKindOfClass:NSString.class]) return nil; |
| 1372 | 1385 | if (![dict[@"trees_url"] isKindOfClass:NSString.class]) return nil; |
| 1373 | - if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1386 | + if (dict[@"updated_at"] && [dict[@"updated_at"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 1387 | + if (dict[@"updated_at"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"updated_at"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"updated_at"] substringToIndex:10]]) return nil; | |
| 1374 | 1388 | if (![dict[@"updated_at"] isKindOfClass:NSString.class]) return nil; |
| 1375 | 1389 | if (![dict[@"url"] isKindOfClass:NSString.class]) return nil; |
| 1376 | 1390 | if (![dict[@"watchers"] isKindOfClass:NSNumber.class]) return nil; |
Mphpdefault / TopLevel.php+64 −0
| @@ -89,6 +89,10 @@ class TopLevel { | ||
| 89 | 89 | */ |
| 90 | 90 | public static function fromCreatedAt(string $value): DateTime { |
| 91 | 91 | $tmp = new DateTime($value); |
| 92 | + $errors = DateTime::getLastErrors(); | |
| 93 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 94 | + throw new Exception('Invalid date-time'); | |
| 95 | + } | |
| 92 | 96 | if (!is_a($tmp, 'DateTime')) { |
| 93 | 97 | throw new Exception('Attribute Error:TopLevel::'); |
| 94 | 98 | } |
| @@ -2082,6 +2086,10 @@ class Comment { | ||
| 2082 | 2086 | */ |
| 2083 | 2087 | public static function fromCreatedAt(string $value): DateTime { |
| 2084 | 2088 | $tmp = new DateTime($value); |
| 2089 | + $errors = DateTime::getLastErrors(); | |
| 2090 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 2091 | + throw new Exception('Invalid date-time'); | |
| 2092 | + } | |
| 2085 | 2093 | if (!is_a($tmp, 'DateTime')) { |
| 2086 | 2094 | throw new Exception('Attribute Error:Comment::'); |
| 2087 | 2095 | } |
| @@ -2277,6 +2285,10 @@ class Comment { | ||
| 2277 | 2285 | */ |
| 2278 | 2286 | public static function fromUpdatedAt(string $value): DateTime { |
| 2279 | 2287 | $tmp = new DateTime($value); |
| 2288 | + $errors = DateTime::getLastErrors(); | |
| 2289 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 2290 | + throw new Exception('Invalid date-time'); | |
| 2291 | + } | |
| 2280 | 2292 | if (!is_a($tmp, 'DateTime')) { |
| 2281 | 2293 | throw new Exception('Attribute Error:Comment::'); |
| 2282 | 2294 | } |
| @@ -4299,6 +4311,10 @@ class Issue { | ||
| 4299 | 4311 | public static function fromClosedAt(?string $value): ?DateTime { |
| 4300 | 4312 | if (!is_null($value)) { |
| 4301 | 4313 | $tmp = new DateTime($value); |
| 4314 | + $errors = DateTime::getLastErrors(); | |
| 4315 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 4316 | + throw new Exception('Invalid date-time'); | |
| 4317 | + } | |
| 4302 | 4318 | if (!is_a($tmp, 'DateTime')) { |
| 4303 | 4319 | throw new Exception('Attribute Error:Issue::'); |
| 4304 | 4320 | } |
| @@ -4456,6 +4472,10 @@ class Issue { | ||
| 4456 | 4472 | */ |
| 4457 | 4473 | public static function fromCreatedAt(string $value): DateTime { |
| 4458 | 4474 | $tmp = new DateTime($value); |
| 4475 | + $errors = DateTime::getLastErrors(); | |
| 4476 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 4477 | + throw new Exception('Invalid date-time'); | |
| 4478 | + } | |
| 4459 | 4479 | if (!is_a($tmp, 'DateTime')) { |
| 4460 | 4480 | throw new Exception('Attribute Error:Issue::'); |
| 4461 | 4481 | } |
| @@ -5108,6 +5128,10 @@ class Issue { | ||
| 5108 | 5128 | */ |
| 5109 | 5129 | public static function fromUpdatedAt(string $value): DateTime { |
| 5110 | 5130 | $tmp = new DateTime($value); |
| 5131 | + $errors = DateTime::getLastErrors(); | |
| 5132 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 5133 | + throw new Exception('Invalid date-time'); | |
| 5134 | + } | |
| 5111 | 5135 | if (!is_a($tmp, 'DateTime')) { |
| 5112 | 5136 | throw new Exception('Attribute Error:Issue::'); |
| 5113 | 5137 | } |
| @@ -5923,6 +5947,10 @@ class Milestone { | ||
| 5923 | 5947 | */ |
| 5924 | 5948 | public static function fromCreatedAt(string $value): DateTime { |
| 5925 | 5949 | $tmp = new DateTime($value); |
| 5950 | + $errors = DateTime::getLastErrors(); | |
| 5951 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 5952 | + throw new Exception('Invalid date-time'); | |
| 5953 | + } | |
| 5926 | 5954 | if (!is_a($tmp, 'DateTime')) { |
| 5927 | 5955 | throw new Exception('Attribute Error:Milestone::'); |
| 5928 | 5956 | } |
| @@ -6073,6 +6101,10 @@ class Milestone { | ||
| 6073 | 6101 | public static function fromDueOn(?string $value): ?DateTime { |
| 6074 | 6102 | if (!is_null($value)) { |
| 6075 | 6103 | $tmp = new DateTime($value); |
| 6104 | + $errors = DateTime::getLastErrors(); | |
| 6105 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 6106 | + throw new Exception('Invalid date-time'); | |
| 6107 | + } | |
| 6076 | 6108 | if (!is_a($tmp, 'DateTime')) { |
| 6077 | 6109 | throw new Exception('Attribute Error:Milestone::'); |
| 6078 | 6110 | } |
| @@ -6465,6 +6497,10 @@ class Milestone { | ||
| 6465 | 6497 | */ |
| 6466 | 6498 | public static function fromUpdatedAt(string $value): DateTime { |
| 6467 | 6499 | $tmp = new DateTime($value); |
| 6500 | + $errors = DateTime::getLastErrors(); | |
| 6501 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 6502 | + throw new Exception('Invalid date-time'); | |
| 6503 | + } | |
| 6468 | 6504 | if (!is_a($tmp, 'DateTime')) { |
| 6469 | 6505 | throw new Exception('Attribute Error:Milestone::'); |
| 6470 | 6506 | } |
| @@ -7407,6 +7443,10 @@ class PayloadPullRequest { | ||
| 7407 | 7443 | */ |
| 7408 | 7444 | public static function fromClosedAt(string $value): DateTime { |
| 7409 | 7445 | $tmp = new DateTime($value); |
| 7446 | + $errors = DateTime::getLastErrors(); | |
| 7447 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 7448 | + throw new Exception('Invalid date-time'); | |
| 7449 | + } | |
| 7410 | 7450 | if (!is_a($tmp, 'DateTime')) { |
| 7411 | 7451 | throw new Exception('Attribute Error:PayloadPullRequest::'); |
| 7412 | 7452 | } |
| @@ -7649,6 +7689,10 @@ class PayloadPullRequest { | ||
| 7649 | 7689 | */ |
| 7650 | 7690 | public static function fromCreatedAt(string $value): DateTime { |
| 7651 | 7691 | $tmp = new DateTime($value); |
| 7692 | + $errors = DateTime::getLastErrors(); | |
| 7693 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 7694 | + throw new Exception('Invalid date-time'); | |
| 7695 | + } | |
| 7652 | 7696 | if (!is_a($tmp, 'DateTime')) { |
| 7653 | 7697 | throw new Exception('Attribute Error:PayloadPullRequest::'); |
| 7654 | 7698 | } |
| @@ -8319,6 +8363,10 @@ class PayloadPullRequest { | ||
| 8319 | 8363 | */ |
| 8320 | 8364 | public static function fromMergedAt(string $value): DateTime { |
| 8321 | 8365 | $tmp = new DateTime($value); |
| 8366 | + $errors = DateTime::getLastErrors(); | |
| 8367 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 8368 | + throw new Exception('Invalid date-time'); | |
| 8369 | + } | |
| 8322 | 8370 | if (!is_a($tmp, 'DateTime')) { |
| 8323 | 8371 | throw new Exception('Attribute Error:PayloadPullRequest::'); |
| 8324 | 8372 | } |
| @@ -8955,6 +9003,10 @@ class PayloadPullRequest { | ||
| 8955 | 9003 | */ |
| 8956 | 9004 | public static function fromUpdatedAt(string $value): DateTime { |
| 8957 | 9005 | $tmp = new DateTime($value); |
| 9006 | + $errors = DateTime::getLastErrors(); | |
| 9007 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 9008 | + throw new Exception('Invalid date-time'); | |
| 9009 | + } | |
| 8958 | 9010 | if (!is_a($tmp, 'DateTime')) { |
| 8959 | 9011 | throw new Exception('Attribute Error:PayloadPullRequest::'); |
| 8960 | 9012 | } |
| @@ -10490,6 +10542,10 @@ class BaseRepo { | ||
| 10490 | 10542 | */ |
| 10491 | 10543 | public static function fromCreatedAt(string $value): DateTime { |
| 10492 | 10544 | $tmp = new DateTime($value); |
| 10545 | + $errors = DateTime::getLastErrors(); | |
| 10546 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 10547 | + throw new Exception('Invalid date-time'); | |
| 10548 | + } | |
| 10493 | 10549 | if (!is_a($tmp, 'DateTime')) { |
| 10494 | 10550 | throw new Exception('Attribute Error:BaseRepo::'); |
| 10495 | 10551 | } |
| @@ -12428,6 +12484,10 @@ class BaseRepo { | ||
| 12428 | 12484 | */ |
| 12429 | 12485 | public static function fromPushedAt(string $value): DateTime { |
| 12430 | 12486 | $tmp = new DateTime($value); |
| 12487 | + $errors = DateTime::getLastErrors(); | |
| 12488 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 12489 | + throw new Exception('Invalid date-time'); | |
| 12490 | + } | |
| 12431 | 12491 | if (!is_a($tmp, 'DateTime')) { |
| 12432 | 12492 | throw new Exception('Attribute Error:BaseRepo::'); |
| 12433 | 12493 | } |
| @@ -13046,6 +13106,10 @@ class BaseRepo { | ||
| 13046 | 13106 | */ |
| 13047 | 13107 | public static function fromUpdatedAt(string $value): DateTime { |
| 13048 | 13108 | $tmp = new DateTime($value); |
| 13109 | + $errors = DateTime::getLastErrors(); | |
| 13110 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 13111 | + throw new Exception('Invalid date-time'); | |
| 13112 | + } | |
| 13049 | 13113 | if (!is_a($tmp, 'DateTime')) { |
| 13050 | 13114 | throw new Exception('Attribute Error:BaseRepo::'); |
| 13051 | 13115 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -1663,7 +1663,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 1663 | 1663 | let decoder = JSONDecoder() |
| 1664 | 1664 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 1665 | 1665 | let container = try decoder.singleValueContainer() |
| 1666 | - let dateStr = try container.decode(String.self) | |
| 1666 | + let dateStr = try container.decode(String.self).uppercased() | |
| 1667 | 1667 | |
| 1668 | 1668 | let formatter = DateFormatter() |
| 1669 | 1669 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/samples/kitchen-sink.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -314,7 +314,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 314 | 314 | let decoder = JSONDecoder() |
| 315 | 315 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 316 | 316 | let container = try decoder.singleValueContainer() |
| 317 | - let dateStr = try container.decode(String.self) | |
| 317 | + let dateStr = try container.decode(String.self).uppercased() | |
| 318 | 318 | |
| 319 | 319 | let formatter = DateFormatter() |
| 320 | 320 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
3 generated files · +6 −2test/inputs/json/samples/null-safe.json
Mcplusplusdefault / quicktype.hpp+1 −1
| @@ -183,7 +183,7 @@ namespace quicktype { | ||
| 183 | 183 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 184 | 184 | if (j.find("address") != j.end() && j.at("address").is_null()) throw std::runtime_error("Unexpected null"); |
| 185 | 185 | x.set_address(get_stack_optional<Address>(j, "address")); |
| 186 | - if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 186 | + if (j.find("created_at") != j.end() && !std::regex_match(j.at("created_at").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 187 | 187 | if (j.find("created_at") != j.end() && j.at("created_at").is_null()) throw std::runtime_error("Unexpected null"); |
| 188 | 188 | x.set_created_at(get_stack_optional<std::string>(j, "created_at")); |
| 189 | 189 | x.set_name(j.at("name").get<std::string>()); |
Mphpdefault / TopLevel.php+4 −0
| @@ -201,6 +201,10 @@ class Item { | ||
| 201 | 201 | public static function fromCreatedAt(?string $value): ?DateTime { |
| 202 | 202 | if (!is_null($value)) { |
| 203 | 203 | $tmp = new DateTime($value); |
| 204 | + $errors = DateTime::getLastErrors(); | |
| 205 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 206 | + throw new Exception('Invalid date-time'); | |
| 207 | + } | |
| 204 | 208 | if (!is_a($tmp, 'DateTime')) { |
| 205 | 209 | throw new Exception('Attribute Error:Item::'); |
| 206 | 210 | } |
Mswiftdefault / quicktype.swift+1 −1
| @@ -163,7 +163,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 163 | 163 | let decoder = JSONDecoder() |
| 164 | 164 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 165 | 165 | let container = try decoder.singleValueContainer() |
| 166 | - let dateStr = try container.decode(String.self) | |
| 166 | + let dateStr = try container.decode(String.self).uppercased() | |
| 167 | 167 | |
| 168 | 168 | let formatter = DateFormatter() |
| 169 | 169 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/samples/objc-control-characters.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -68,7 +68,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 68 | 68 | let decoder = JSONDecoder() |
| 69 | 69 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 70 | 70 | let container = try decoder.singleValueContainer() |
| 71 | - let dateStr = try container.decode(String.self) | |
| 71 | + let dateStr = try container.decode(String.self).uppercased() | |
| 72 | 72 | |
| 73 | 73 | let formatter = DateFormatter() |
| 74 | 74 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
3 generated files · +3 −3test/inputs/json/samples/pokedex.json
Mswift-sendable-objective-cdefault / quicktype.swift+1 −1
| @@ -272,7 +272,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 272 | 272 | let decoder = JSONDecoder() |
| 273 | 273 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 274 | 274 | let container = try decoder.singleValueContainer() |
| 275 | - let dateStr = try container.decode(String.self) | |
| 275 | + let dateStr = try container.decode(String.self).uppercased() | |
| 276 | 276 | |
| 277 | 277 | let formatter = DateFormatter() |
| 278 | 278 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswift-sendable-objective-cstruct-or-class-struct--aa0cc2601d8a / quicktype.swift+1 −1
| @@ -240,7 +240,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 240 | 240 | let decoder = JSONDecoder() |
| 241 | 241 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 242 | 242 | let container = try decoder.singleValueContainer() |
| 243 | - let dateStr = try container.decode(String.self) | |
| 243 | + let dateStr = try container.decode(String.self).uppercased() | |
| 244 | 244 | |
| 245 | 245 | let formatter = DateFormatter() |
| 246 | 246 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftdefault / quicktype.swift+1 −1
| @@ -240,7 +240,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 240 | 240 | let decoder = JSONDecoder() |
| 241 | 241 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 242 | 242 | let container = try decoder.singleValueContainer() |
| 243 | - let dateStr = try container.decode(String.self) | |
| 243 | + let dateStr = try container.decode(String.self).uppercased() | |
| 244 | 244 | |
| 245 | 245 | let formatter = DateFormatter() |
| 246 | 246 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/samples/reddit.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -798,7 +798,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 798 | 798 | let decoder = JSONDecoder() |
| 799 | 799 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 800 | 800 | let container = try decoder.singleValueContainer() |
| 801 | - let dateStr = try container.decode(String.self) | |
| 801 | + let dateStr = try container.decode(String.self).uppercased() | |
| 802 | 802 | |
| 803 | 803 | let formatter = DateFormatter() |
| 804 | 804 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +4 −4test/inputs/json/samples/simple-object.json
Mswiftcoding-keys-protocol-CaseIterable--169323764eaa / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftfinal-classes-true__struct-or-class-class--d3c62ec7414d / quicktype.swift+1 −1
| @@ -70,7 +70,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 70 | 70 | let decoder = JSONDecoder() |
| 71 | 71 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 72 | 72 | let container = try decoder.singleValueContainer() |
| 73 | - let dateStr = try container.decode(String.self) | |
| 73 | + let dateStr = try container.decode(String.self).uppercased() | |
| 74 | 74 | |
| 75 | 75 | let formatter = DateFormatter() |
| 76 | 76 | formatter.calendar = Calendar(identifier: .iso8601) |
Mswiftprotocol-hashable--739b516c7897 / quicktype.swift+1 −1
| @@ -69,7 +69,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 69 | 69 | let decoder = JSONDecoder() |
| 70 | 70 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 71 | 71 | let container = try decoder.singleValueContainer() |
| 72 | - let dateStr = try container.decode(String.self) | |
| 72 | + let dateStr = try container.decode(String.self).uppercased() | |
| 73 | 73 | |
| 74 | 74 | let formatter = DateFormatter() |
| 75 | 75 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/samples/spotify-album.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -531,7 +531,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 531 | 531 | let decoder = JSONDecoder() |
| 532 | 532 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 533 | 533 | let container = try decoder.singleValueContainer() |
| 534 | - let dateStr = try container.decode(String.self) | |
| 534 | + let dateStr = try container.decode(String.self).uppercased() | |
| 535 | 535 | |
| 536 | 536 | let formatter = DateFormatter() |
| 537 | 537 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/samples/us-avg-temperatures.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -163,7 +163,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 163 | 163 | let decoder = JSONDecoder() |
| 164 | 164 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 165 | 165 | let container = try decoder.singleValueContainer() |
| 166 | - let dateStr = try container.decode(String.self) | |
| 166 | + let dateStr = try container.decode(String.self).uppercased() | |
| 167 | 167 | |
| 168 | 168 | let formatter = DateFormatter() |
| 169 | 169 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/json/samples/us-senators.json
Mswiftdefault / quicktype.swift+1 −1
| @@ -463,7 +463,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 463 | 463 | let decoder = JSONDecoder() |
| 464 | 464 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 465 | 465 | let container = try decoder.singleValueContainer() |
| 466 | - let dateStr = try container.decode(String.self) | |
| 466 | + let dateStr = try container.decode(String.self).uppercased() | |
| 467 | 467 | |
| 468 | 468 | let formatter = DateFormatter() |
| 469 | 469 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/accessors.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -101,7 +101,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 101 | 101 | let decoder = JSONDecoder() |
| 102 | 102 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 103 | 103 | let container = try decoder.singleValueContainer() |
| 104 | - let dateStr = try container.decode(String.self) | |
| 104 | + let dateStr = try container.decode(String.self).uppercased() | |
| 105 | 105 | |
| 106 | 106 | let formatter = DateFormatter() |
| 107 | 107 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/all-of-additional-properties-false.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -78,7 +78,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 78 | 78 | let decoder = JSONDecoder() |
| 79 | 79 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 80 | 80 | let container = try decoder.singleValueContainer() |
| 81 | - let dateStr = try container.decode(String.self) | |
| 81 | + let dateStr = try container.decode(String.self).uppercased() | |
| 82 | 82 | |
| 83 | 83 | let formatter = DateFormatter() |
| 84 | 84 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/any.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -59,7 +59,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 59 | 59 | let decoder = JSONDecoder() |
| 60 | 60 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 61 | 61 | let container = try decoder.singleValueContainer() |
| 62 | - let dateStr = try container.decode(String.self) | |
| 62 | + let dateStr = try container.decode(String.self).uppercased() | |
| 63 | 63 | |
| 64 | 64 | let formatter = DateFormatter() |
| 65 | 65 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/bool-string.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -107,7 +107,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 107 | 107 | let decoder = JSONDecoder() |
| 108 | 108 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 109 | 109 | let container = try decoder.singleValueContainer() |
| 110 | - let dateStr = try container.decode(String.self) | |
| 110 | + let dateStr = try container.decode(String.self).uppercased() | |
| 111 | 111 | |
| 112 | 112 | let formatter = DateFormatter() |
| 113 | 113 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/boolean-subschema.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -67,7 +67,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 67 | 67 | let decoder = JSONDecoder() |
| 68 | 68 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 69 | 69 | let container = try decoder.singleValueContainer() |
| 70 | - let dateStr = try container.decode(String.self) | |
| 70 | + let dateStr = try container.decode(String.self).uppercased() | |
| 71 | 71 | |
| 72 | 72 | let formatter = DateFormatter() |
| 73 | 73 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/camelCase.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -59,7 +59,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 59 | 59 | let decoder = JSONDecoder() |
| 60 | 60 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 61 | 61 | let container = try decoder.singleValueContainer() |
| 62 | - let dateStr = try container.decode(String.self) | |
| 62 | + let dateStr = try container.decode(String.self).uppercased() | |
| 63 | 63 | |
| 64 | 64 | let formatter = DateFormatter() |
| 65 | 65 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/class-map-union.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -141,7 +141,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 141 | 141 | let decoder = JSONDecoder() |
| 142 | 142 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 143 | 143 | let container = try decoder.singleValueContainer() |
| 144 | - let dateStr = try container.decode(String.self) | |
| 144 | + let dateStr = try container.decode(String.self).uppercased() | |
| 145 | 145 | |
| 146 | 146 | let formatter = DateFormatter() |
| 147 | 147 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/class-with-additional.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -83,7 +83,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 83 | 83 | let decoder = JSONDecoder() |
| 84 | 84 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 85 | 85 | let container = try decoder.singleValueContainer() |
| 86 | - let dateStr = try container.decode(String.self) | |
| 86 | + let dateStr = try container.decode(String.self).uppercased() | |
| 87 | 87 | |
| 88 | 88 | let formatter = DateFormatter() |
| 89 | 89 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/comment-injection-enum-nested-comment.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -67,7 +67,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 67 | 67 | let decoder = JSONDecoder() |
| 68 | 68 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 69 | 69 | let container = try decoder.singleValueContainer() |
| 70 | - let dateStr = try container.decode(String.self) | |
| 70 | + let dateStr = try container.decode(String.self).uppercased() | |
| 71 | 71 | |
| 72 | 72 | let formatter = DateFormatter() |
| 73 | 73 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/comment-injection-enum.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -73,7 +73,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 73 | 73 | let decoder = JSONDecoder() |
| 74 | 74 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 75 | 75 | let container = try decoder.singleValueContainer() |
| 76 | - let dateStr = try container.decode(String.self) | |
| 76 | + let dateStr = try container.decode(String.self).uppercased() | |
| 77 | 77 | |
| 78 | 78 | let formatter = DateFormatter() |
| 79 | 79 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/comment-injection-nested-comment.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/comment-injection.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -94,7 +94,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 94 | 94 | let decoder = JSONDecoder() |
| 95 | 95 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 96 | 96 | let container = try decoder.singleValueContainer() |
| 97 | - let dateStr = try container.decode(String.self) | |
| 97 | + let dateStr = try container.decode(String.self).uppercased() | |
| 98 | 98 | |
| 99 | 99 | let formatter = DateFormatter() |
| 100 | 100 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/const-non-string.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -75,7 +75,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 75 | 75 | let decoder = JSONDecoder() |
| 76 | 76 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 77 | 77 | let container = try decoder.singleValueContainer() |
| 78 | - let dateStr = try container.decode(String.self) | |
| 78 | + let dateStr = try container.decode(String.self).uppercased() | |
| 79 | 79 | |
| 80 | 80 | let formatter = DateFormatter() |
| 81 | 81 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/constructor.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -126,7 +126,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 126 | 126 | let decoder = JSONDecoder() |
| 127 | 127 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 128 | 128 | let container = try decoder.singleValueContainer() |
| 129 | - let dateStr = try container.decode(String.self) | |
| 129 | + let dateStr = try container.decode(String.self).uppercased() | |
| 130 | 130 | |
| 131 | 131 | let formatter = DateFormatter() |
| 132 | 132 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/cut-enum.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
2 generated files · +5 −1test/inputs/schema/date-time-or-string.schema
Mschema-phpdefault / TopLevel.php+4 −0
| @@ -26,6 +26,10 @@ class TopLevel { | ||
| 26 | 26 | return Bar::from($value); /*enum*/ |
| 27 | 27 | } elseif (is_string($value)) { |
| 28 | 28 | $tmp = new DateTime($value); |
| 29 | + $errors = DateTime::getLastErrors(); | |
| 30 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 31 | + throw new Exception('Invalid date-time'); | |
| 32 | + } | |
| 29 | 33 | if (!is_a($tmp, 'DateTime')) { |
| 30 | 34 | throw new Exception('Attribute Error:TopLevel::'); |
| 31 | 35 | } |
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -91,7 +91,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 91 | 91 | let decoder = JSONDecoder() |
| 92 | 92 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 93 | 93 | let container = try decoder.singleValueContainer() |
| 94 | - let dateStr = try container.decode(String.self) | |
| 94 | + let dateStr = try container.decode(String.self).uppercased() | |
| 95 | 95 | |
| 96 | 96 | let formatter = DateFormatter() |
| 97 | 97 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +12 −3test/inputs/schema/date-time.schema
Mschema-cplusplusdefault / quicktype.hpp+1 −1
| @@ -234,7 +234,7 @@ namespace quicktype { | ||
| 234 | 234 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 235 | 235 | x.set_complex_union_array(j.at("complex-union-array").get<std::vector<ComplexUnionArrayElement>>()); |
| 236 | 236 | x.set_date(j.at("date").get<std::string>()); |
| 237 | - if (j.find("date-time") != j.end() && !std::regex_match(j.at("date-time").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 237 | + if (j.find("date-time") != j.end() && !std::regex_match(j.at("date-time").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 238 | 238 | x.set_date_time(j.at("date-time").get<std::string>()); |
| 239 | 239 | if (j.find("local-date-class") != j.end() && j.at("local-date-class").is_null()) throw std::runtime_error("Unexpected null"); |
| 240 | 240 | x.set_local_date_class(get_stack_optional<LocalDate>(j, "local-date-class")); |
Mschema-objective-cdefault / QTTopLevel.m+2 −1
| @@ -139,7 +139,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 139 | 139 | if (self = [super init]) { |
| 140 | 140 | if (![dict[@"complex-union-array"] isKindOfClass:NSArray.class]) return nil; |
| 141 | 141 | if (![dict[@"date"] isKindOfClass:NSString.class]) return nil; |
| 142 | - if (dict[@"date-time"] && [dict[@"date-time"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 142 | + if (dict[@"date-time"] && [dict[@"date-time"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 143 | + if (dict[@"date-time"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"date-time"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"date-time"] substringToIndex:10]]) return nil; | |
| 143 | 144 | if (![dict[@"date-time"] isKindOfClass:NSString.class]) return nil; |
| 144 | 145 | if (![dict[@"time"] isKindOfClass:NSString.class]) return nil; |
| 145 | 146 | if (![dict[@"union-array"] isKindOfClass:NSArray.class]) return nil; |
Mschema-phpdefault / TopLevel.php+8 −0
| @@ -45,6 +45,10 @@ class TopLevel { | ||
| 45 | 45 | return ComplexUnionArray::from($value); /*enum*/ |
| 46 | 46 | } elseif (is_string($value)) { |
| 47 | 47 | $tmp = new DateTime($value); |
| 48 | + $errors = DateTime::getLastErrors(); | |
| 49 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 50 | + throw new Exception('Invalid date-time'); | |
| 51 | + } | |
| 48 | 52 | if (!is_a($tmp, 'DateTime')) { |
| 49 | 53 | throw new Exception('Attribute Error:TopLevel::'); |
| 50 | 54 | } |
| @@ -179,6 +183,10 @@ class TopLevel { | ||
| 179 | 183 | */ |
| 180 | 184 | public static function fromDateTime(string $value): DateTime { |
| 181 | 185 | $tmp = new DateTime($value); |
| 186 | + $errors = DateTime::getLastErrors(); | |
| 187 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 188 | + throw new Exception('Invalid date-time'); | |
| 189 | + } | |
| 182 | 190 | if (!is_a($tmp, 'DateTime')) { |
| 183 | 191 | throw new Exception('Attribute Error:TopLevel::'); |
| 184 | 192 | } |
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -252,7 +252,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 252 | 252 | let decoder = JSONDecoder() |
| 253 | 253 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 254 | 254 | let container = try decoder.singleValueContainer() |
| 255 | - let dateStr = try container.decode(String.self) | |
| 255 | + let dateStr = try container.decode(String.self).uppercased() | |
| 256 | 256 | |
| 257 | 257 | let formatter = DateFormatter() |
| 258 | 258 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/default-value.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -56,7 +56,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 56 | 56 | let decoder = JSONDecoder() |
| 57 | 57 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 58 | 58 | let container = try decoder.singleValueContainer() |
| 59 | - let dateStr = try container.decode(String.self) | |
| 59 | + let dateStr = try container.decode(String.self).uppercased() | |
| 60 | 60 | |
| 61 | 61 | let formatter = DateFormatter() |
| 62 | 62 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/description-with-double-quotes.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -56,7 +56,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 56 | 56 | let decoder = JSONDecoder() |
| 57 | 57 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 58 | 58 | let container = try decoder.singleValueContainer() |
| 59 | - let dateStr = try container.decode(String.self) | |
| 59 | + let dateStr = try container.decode(String.self).uppercased() | |
| 60 | 60 | |
| 61 | 61 | let formatter = DateFormatter() |
| 62 | 62 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/description.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -184,7 +184,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 184 | 184 | let decoder = JSONDecoder() |
| 185 | 185 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 186 | 186 | let container = try decoder.singleValueContainer() |
| 187 | - let dateStr = try container.decode(String.self) | |
| 187 | + let dateStr = try container.decode(String.self).uppercased() | |
| 188 | 188 | |
| 189 | 189 | let formatter = DateFormatter() |
| 190 | 190 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/direct-union.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -542,7 +542,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 542 | 542 | let decoder = JSONDecoder() |
| 543 | 543 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 544 | 544 | let container = try decoder.singleValueContainer() |
| 545 | - let dateStr = try container.decode(String.self) | |
| 545 | + let dateStr = try container.decode(String.self).uppercased() | |
| 546 | 546 | |
| 547 | 547 | let formatter = DateFormatter() |
| 548 | 548 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/empty-object.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -37,7 +37,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 37 | 37 | let decoder = JSONDecoder() |
| 38 | 38 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 39 | 39 | let container = try decoder.singleValueContainer() |
| 40 | - let dateStr = try container.decode(String.self) | |
| 40 | + let dateStr = try container.decode(String.self).uppercased() | |
| 41 | 41 | |
| 42 | 42 | let formatter = DateFormatter() |
| 43 | 43 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/enum-large.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -88,7 +88,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 88 | 88 | let decoder = JSONDecoder() |
| 89 | 89 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 90 | 90 | let container = try decoder.singleValueContainer() |
| 91 | - let dateStr = try container.decode(String.self) | |
| 91 | + let dateStr = try container.decode(String.self).uppercased() | |
| 92 | 92 | |
| 93 | 93 | let formatter = DateFormatter() |
| 94 | 94 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/enum-with-null.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -60,7 +60,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 60 | 60 | let decoder = JSONDecoder() |
| 61 | 61 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 62 | 62 | let container = try decoder.singleValueContainer() |
| 63 | - let dateStr = try container.decode(String.self) | |
| 63 | + let dateStr = try container.decode(String.self).uppercased() | |
| 64 | 64 | |
| 65 | 65 | let formatter = DateFormatter() |
| 66 | 66 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/enum-with-values.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -65,7 +65,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 65 | 65 | let decoder = JSONDecoder() |
| 66 | 66 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 67 | 67 | let container = try decoder.singleValueContainer() |
| 68 | - let dateStr = try container.decode(String.self) | |
| 68 | + let dateStr = try container.decode(String.self).uppercased() | |
| 69 | 69 | |
| 70 | 70 | let formatter = DateFormatter() |
| 71 | 71 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/enum.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -117,7 +117,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 117 | 117 | let decoder = JSONDecoder() |
| 118 | 118 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 119 | 119 | let container = try decoder.singleValueContainer() |
| 120 | - let dateStr = try container.decode(String.self) | |
| 120 | + let dateStr = try container.decode(String.self).uppercased() | |
| 121 | 121 | |
| 122 | 122 | let formatter = DateFormatter() |
| 123 | 123 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/fractional-bounds.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/go-schema-pattern-properties.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/haskell-enum-forbidden.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -60,7 +60,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 60 | 60 | let decoder = JSONDecoder() |
| 61 | 61 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 62 | 62 | let container = try decoder.singleValueContainer() |
| 63 | - let dateStr = try container.decode(String.self) | |
| 63 | + let dateStr = try container.decode(String.self).uppercased() | |
| 64 | 64 | |
| 65 | 65 | let formatter = DateFormatter() |
| 66 | 66 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/id-no-address.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/id-root.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/ie-suffix-singularization.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/implicit-all-of.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/implicit-class-array-union.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -162,7 +162,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 162 | 162 | let decoder = JSONDecoder() |
| 163 | 163 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 164 | 164 | let container = try decoder.singleValueContainer() |
| 165 | - let dateStr = try container.decode(String.self) | |
| 165 | + let dateStr = try container.decode(String.self).uppercased() | |
| 166 | 166 | |
| 167 | 167 | let formatter = DateFormatter() |
| 168 | 168 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/implicit-one-of.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/integer-before-number.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -40,7 +40,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 40 | 40 | let decoder = JSONDecoder() |
| 41 | 41 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 42 | 42 | let container = try decoder.singleValueContainer() |
| 43 | - let dateStr = try container.decode(String.self) | |
| 43 | + let dateStr = try container.decode(String.self).uppercased() | |
| 44 | 44 | |
| 45 | 45 | let formatter = DateFormatter() |
| 46 | 46 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/integer-float-union.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -83,7 +83,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 83 | 83 | let decoder = JSONDecoder() |
| 84 | 84 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 85 | 85 | let container = try decoder.singleValueContainer() |
| 86 | - let dateStr = try container.decode(String.self) | |
| 86 | + let dateStr = try container.decode(String.self).uppercased() | |
| 87 | 87 | |
| 88 | 88 | let formatter = DateFormatter() |
| 89 | 89 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/integer-string.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -107,7 +107,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 107 | 107 | let decoder = JSONDecoder() |
| 108 | 108 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 109 | 109 | let container = try decoder.singleValueContainer() |
| 110 | - let dateStr = try container.decode(String.self) | |
| 110 | + let dateStr = try container.decode(String.self).uppercased() | |
| 111 | 111 | |
| 112 | 112 | let formatter = DateFormatter() |
| 113 | 113 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/integer-type.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -87,7 +87,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 87 | 87 | let decoder = JSONDecoder() |
| 88 | 88 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 89 | 89 | let container = try decoder.singleValueContainer() |
| 90 | - let dateStr = try container.decode(String.self) | |
| 90 | + let dateStr = try container.decode(String.self).uppercased() | |
| 91 | 91 | |
| 92 | 92 | let formatter = DateFormatter() |
| 93 | 93 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/intersection-nested.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/intersection.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/issue2680-top-level-array.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -37,7 +37,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 37 | 37 | let decoder = JSONDecoder() |
| 38 | 38 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 39 | 39 | let container = try decoder.singleValueContainer() |
| 40 | - let dateStr = try container.decode(String.self) | |
| 40 | + let dateStr = try container.decode(String.self).uppercased() | |
| 41 | 41 | |
| 42 | 42 | let formatter = DateFormatter() |
| 43 | 43 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/keyword-enum.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -416,7 +416,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 416 | 416 | let decoder = JSONDecoder() |
| 417 | 417 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 418 | 418 | let container = try decoder.singleValueContainer() |
| 419 | - let dateStr = try container.decode(String.self) | |
| 419 | + let dateStr = try container.decode(String.self).uppercased() | |
| 420 | 420 | |
| 421 | 421 | let formatter = DateFormatter() |
| 422 | 422 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/keyword-unions.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -26830,7 +26830,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 26830 | 26830 | let decoder = JSONDecoder() |
| 26831 | 26831 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 26832 | 26832 | let container = try decoder.singleValueContainer() |
| 26833 | - let dateStr = try container.decode(String.self) | |
| 26833 | + let dateStr = try container.decode(String.self).uppercased() | |
| 26834 | 26834 | |
| 26835 | 26835 | let formatter = DateFormatter() |
| 26836 | 26836 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/light.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -107,7 +107,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 107 | 107 | let decoder = JSONDecoder() |
| 108 | 108 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 109 | 109 | let container = try decoder.singleValueContainer() |
| 110 | - let dateStr = try container.decode(String.self) | |
| 110 | + let dateStr = try container.decode(String.self).uppercased() | |
| 111 | 111 | |
| 112 | 112 | let formatter = DateFormatter() |
| 113 | 113 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/list.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -61,7 +61,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 61 | 61 | let decoder = JSONDecoder() |
| 62 | 62 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 63 | 63 | let container = try decoder.singleValueContainer() |
| 64 | - let dateStr = try container.decode(String.self) | |
| 64 | + let dateStr = try container.decode(String.self).uppercased() | |
| 65 | 65 | |
| 66 | 66 | let formatter = DateFormatter() |
| 67 | 67 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/min-max-items.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -99,7 +99,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 99 | 99 | let decoder = JSONDecoder() |
| 100 | 100 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 101 | 101 | let container = try decoder.singleValueContainer() |
| 102 | - let dateStr = try container.decode(String.self) | |
| 102 | + let dateStr = try container.decode(String.self).uppercased() | |
| 103 | 103 | |
| 104 | 104 | let formatter = DateFormatter() |
| 105 | 105 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/minmax-integer.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -83,7 +83,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 83 | 83 | let decoder = JSONDecoder() |
| 84 | 84 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 85 | 85 | let container = try decoder.singleValueContainer() |
| 86 | - let dateStr = try container.decode(String.self) | |
| 86 | + let dateStr = try container.decode(String.self).uppercased() | |
| 87 | 87 | |
| 88 | 88 | let formatter = DateFormatter() |
| 89 | 89 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/minmax.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -83,7 +83,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 83 | 83 | let decoder = JSONDecoder() |
| 84 | 84 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 85 | 85 | let container = try decoder.singleValueContainer() |
| 86 | - let dateStr = try container.decode(String.self) | |
| 86 | + let dateStr = try container.decode(String.self).uppercased() | |
| 87 | 87 | |
| 88 | 88 | let formatter = DateFormatter() |
| 89 | 89 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/minmaxlength.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -111,7 +111,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 111 | 111 | let decoder = JSONDecoder() |
| 112 | 112 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 113 | 113 | let container = try decoder.singleValueContainer() |
| 114 | - let dateStr = try container.decode(String.self) | |
| 114 | + let dateStr = try container.decode(String.self).uppercased() | |
| 115 | 115 | |
| 116 | 116 | let formatter = DateFormatter() |
| 117 | 117 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/multi-type-enum.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -103,7 +103,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 103 | 103 | let decoder = JSONDecoder() |
| 104 | 104 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 105 | 105 | let container = try decoder.singleValueContainer() |
| 106 | - let dateStr = try container.decode(String.self) | |
| 106 | + let dateStr = try container.decode(String.self).uppercased() | |
| 107 | 107 | |
| 108 | 108 | let formatter = DateFormatter() |
| 109 | 109 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/mutually-recursive.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -132,7 +132,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 132 | 132 | let decoder = JSONDecoder() |
| 133 | 133 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 134 | 134 | let container = try decoder.singleValueContainer() |
| 135 | - let dateStr = try container.decode(String.self) | |
| 135 | + let dateStr = try container.decode(String.self).uppercased() | |
| 136 | 136 | |
| 137 | 137 | let formatter = DateFormatter() |
| 138 | 138 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/nested-intersection-union.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -111,7 +111,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 111 | 111 | let decoder = JSONDecoder() |
| 112 | 112 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 113 | 113 | let container = try decoder.singleValueContainer() |
| 114 | - let dateStr = try container.decode(String.self) | |
| 114 | + let dateStr = try container.decode(String.self).uppercased() | |
| 115 | 115 | |
| 116 | 116 | let formatter = DateFormatter() |
| 117 | 117 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/non-standard-ref.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/nullable-optional-one-of.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -64,7 +64,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 64 | 64 | let decoder = JSONDecoder() |
| 65 | 65 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 66 | 66 | let container = try decoder.singleValueContainer() |
| 67 | - let dateStr = try container.decode(String.self) | |
| 67 | + let dateStr = try container.decode(String.self).uppercased() | |
| 68 | 68 | |
| 69 | 69 | let formatter = DateFormatter() |
| 70 | 70 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/object-type-required.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -106,7 +106,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 106 | 106 | let decoder = JSONDecoder() |
| 107 | 107 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 108 | 108 | let container = try decoder.singleValueContainer() |
| 109 | - let dateStr = try container.decode(String.self) | |
| 109 | + let dateStr = try container.decode(String.self).uppercased() | |
| 110 | 110 | |
| 111 | 111 | let formatter = DateFormatter() |
| 112 | 112 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/optional-any.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -59,7 +59,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 59 | 59 | let decoder = JSONDecoder() |
| 60 | 60 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 61 | 61 | let container = try decoder.singleValueContainer() |
| 62 | - let dateStr = try container.decode(String.self) | |
| 62 | + let dateStr = try container.decode(String.self).uppercased() | |
| 63 | 63 | |
| 64 | 64 | let formatter = DateFormatter() |
| 65 | 65 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/optional-const-ref.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -127,7 +127,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 127 | 127 | let decoder = JSONDecoder() |
| 128 | 128 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 129 | 129 | let container = try decoder.singleValueContainer() |
| 130 | - let dateStr = try container.decode(String.self) | |
| 130 | + let dateStr = try container.decode(String.self).uppercased() | |
| 131 | 131 | |
| 132 | 132 | let formatter = DateFormatter() |
| 133 | 133 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/optional-constraints.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -71,7 +71,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 71 | 71 | let decoder = JSONDecoder() |
| 72 | 72 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 73 | 73 | let container = try decoder.singleValueContainer() |
| 74 | - let dateStr = try container.decode(String.self) | |
| 74 | + let dateStr = try container.decode(String.self).uppercased() | |
| 75 | 75 | |
| 76 | 76 | let formatter = DateFormatter() |
| 77 | 77 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
4 generated files · +13 −4test/inputs/schema/optional-date-time.schema
Mschema-cplusplusdefault / quicktype.hpp+2 −2
| @@ -136,13 +136,13 @@ namespace quicktype { | ||
| 136 | 136 | if (!j.is_object()) throw std::runtime_error("Expected object"); |
| 137 | 137 | if (j.find("optional-date") != j.end() && j.at("optional-date").is_null()) throw std::runtime_error("Unexpected null"); |
| 138 | 138 | x.set_optional_date(get_stack_optional<std::string>(j, "optional-date")); |
| 139 | - if (j.find("optional-date-time") != j.end() && !std::regex_match(j.at("optional-date-time").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 139 | + if (j.find("optional-date-time") != j.end() && !std::regex_match(j.at("optional-date-time").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 140 | 140 | if (j.find("optional-date-time") != j.end() && j.at("optional-date-time").is_null()) throw std::runtime_error("Unexpected null"); |
| 141 | 141 | x.set_optional_date_time(get_stack_optional<std::string>(j, "optional-date-time")); |
| 142 | 142 | if (j.find("optional-time") != j.end() && j.at("optional-time").is_null()) throw std::runtime_error("Unexpected null"); |
| 143 | 143 | x.set_optional_time(get_stack_optional<std::string>(j, "optional-time")); |
| 144 | 144 | x.set_required_date(j.at("required-date").get<std::string>()); |
| 145 | - if (j.find("required-date-time") != j.end() && !std::regex_match(j.at("required-date-time").get<std::string>(), std::regex("^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$"))) throw std::runtime_error("Expected date-time"); | |
| 145 | + if (j.find("required-date-time") != j.end() && !std::regex_match(j.at("required-date-time").get<std::string>(), std::regex("^(?:(?:[0-9]{4}-(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01]))|(?:[0-9]{4}-(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30))|(?:[0-9]{4}-02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29))[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:[.][0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$"))) throw std::runtime_error("Expected date-time"); | |
| 146 | 146 | x.set_required_date_time(j.at("required-date-time").get<std::string>()); |
| 147 | 147 | x.set_required_time(j.at("required-time").get<std::string>()); |
| 148 | 148 | } |
Mschema-objective-cdefault / QTTopLevel.m+2 −1
| @@ -82,7 +82,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco | ||
| 82 | 82 | { |
| 83 | 83 | if (self = [super init]) { |
| 84 | 84 | if (![dict[@"required-date"] isKindOfClass:NSString.class]) return nil; |
| 85 | - if (dict[@"required-date-time"] && [dict[@"required-date-time"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}T" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 85 | + if (dict[@"required-date-time"] && [dict[@"required-date-time"] rangeOfString:@"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$" options:NSRegularExpressionSearch].location == NSNotFound) return nil; | |
| 86 | + if (dict[@"required-date-time"] && ![[[[NSISO8601DateFormatter new] stringFromDate:[[NSISO8601DateFormatter new] dateFromString:[[dict[@"required-date-time"] substringToIndex:10] stringByAppendingString:@"T00:00:00Z"]]] substringToIndex:10] isEqualToString:[dict[@"required-date-time"] substringToIndex:10]]) return nil; | |
| 86 | 87 | if (![dict[@"required-date-time"] isKindOfClass:NSString.class]) return nil; |
| 87 | 88 | if (![dict[@"required-time"] isKindOfClass:NSString.class]) return nil; |
| 88 | 89 | [self setValuesForKeysWithDictionary:dict]; |
Mschema-phpdefault / TopLevel.php+8 −0
| @@ -93,6 +93,10 @@ class TopLevel { | ||
| 93 | 93 | public static function fromOptionalDateTime(?string $value): ?DateTime { |
| 94 | 94 | if (!is_null($value)) { |
| 95 | 95 | $tmp = new DateTime($value); |
| 96 | + $errors = DateTime::getLastErrors(); | |
| 97 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 98 | + throw new Exception('Invalid date-time'); | |
| 99 | + } | |
| 96 | 100 | if (!is_a($tmp, 'DateTime')) { |
| 97 | 101 | throw new Exception('Attribute Error:TopLevel::'); |
| 98 | 102 | } |
| @@ -260,6 +264,10 @@ class TopLevel { | ||
| 260 | 264 | */ |
| 261 | 265 | public static function fromRequiredDateTime(string $value): DateTime { |
| 262 | 266 | $tmp = new DateTime($value); |
| 267 | + $errors = DateTime::getLastErrors(); | |
| 268 | + if ($errors && ($errors['warning_count'] || $errors['error_count'])) { | |
| 269 | + throw new Exception('Invalid date-time'); | |
| 270 | + } | |
| 263 | 271 | if (!is_a($tmp, 'DateTime')) { |
| 264 | 272 | throw new Exception('Attribute Error:TopLevel::'); |
| 265 | 273 | } |
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -75,7 +75,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 75 | 75 | let decoder = JSONDecoder() |
| 76 | 76 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 77 | 77 | let container = try decoder.singleValueContainer() |
| 78 | - let dateStr = try container.decode(String.self) | |
| 78 | + let dateStr = try container.decode(String.self).uppercased() | |
| 79 | 79 | |
| 80 | 80 | let formatter = DateFormatter() |
| 81 | 81 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/optional-enum.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -64,7 +64,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 64 | 64 | let decoder = JSONDecoder() |
| 65 | 65 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 66 | 66 | let container = try decoder.singleValueContainer() |
| 67 | - let dateStr = try container.decode(String.self) | |
| 67 | + let dateStr = try container.decode(String.self).uppercased() | |
| 68 | 68 | |
| 69 | 69 | let formatter = DateFormatter() |
| 70 | 70 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/pattern.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -111,7 +111,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 111 | 111 | let decoder = JSONDecoder() |
| 112 | 112 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 113 | 113 | let container = try decoder.singleValueContainer() |
| 114 | - let dateStr = try container.decode(String.self) | |
| 114 | + let dateStr = try container.decode(String.self).uppercased() | |
| 115 | 115 | |
| 116 | 116 | let formatter = DateFormatter() |
| 117 | 117 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/postman-collection.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -108,7 +108,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 108 | 108 | let decoder = JSONDecoder() |
| 109 | 109 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 110 | 110 | let container = try decoder.singleValueContainer() |
| 111 | - let dateStr = try container.decode(String.self) | |
| 111 | + let dateStr = try container.decode(String.self).uppercased() | |
| 112 | 112 | |
| 113 | 113 | let formatter = DateFormatter() |
| 114 | 114 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/prefix-items.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -87,7 +87,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 87 | 87 | let decoder = JSONDecoder() |
| 88 | 88 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 89 | 89 | let container = try decoder.singleValueContainer() |
| 90 | - let dateStr = try container.decode(String.self) | |
| 90 | + let dateStr = try container.decode(String.self).uppercased() | |
| 91 | 91 | |
| 92 | 92 | let formatter = DateFormatter() |
| 93 | 93 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/recursive-union-flattening.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -351,7 +351,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 351 | 351 | let decoder = JSONDecoder() |
| 352 | 352 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 353 | 353 | let container = try decoder.singleValueContainer() |
| 354 | - let dateStr = try container.decode(String.self) | |
| 354 | + let dateStr = try container.decode(String.self).uppercased() | |
| 355 | 355 | |
| 356 | 356 | let formatter = DateFormatter() |
| 357 | 357 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/ref-id-files.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/ref-remote.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -61,7 +61,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 61 | 61 | let decoder = JSONDecoder() |
| 62 | 62 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 63 | 63 | let container = try decoder.singleValueContainer() |
| 64 | - let dateStr = try container.decode(String.self) | |
| 64 | + let dateStr = try container.decode(String.self).uppercased() | |
| 65 | 65 | |
| 66 | 66 | let formatter = DateFormatter() |
| 67 | 67 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/renaming-bug.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -720,7 +720,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 720 | 720 | let decoder = JSONDecoder() |
| 721 | 721 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 722 | 722 | let container = try decoder.singleValueContainer() |
| 723 | - let dateStr = try container.decode(String.self) | |
| 723 | + let dateStr = try container.decode(String.self).uppercased() | |
| 724 | 724 | |
| 725 | 725 | let formatter = DateFormatter() |
| 726 | 726 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/required-draft3.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/required-non-properties.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -59,7 +59,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 59 | 59 | let decoder = JSONDecoder() |
| 60 | 60 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 61 | 61 | let container = try decoder.singleValueContainer() |
| 62 | - let dateStr = try container.decode(String.self) | |
| 62 | + let dateStr = try container.decode(String.self).uppercased() | |
| 63 | 63 | |
| 64 | 64 | let formatter = DateFormatter() |
| 65 | 65 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/required.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/rust-cycle-breaker-union.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -142,7 +142,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 142 | 142 | let decoder = JSONDecoder() |
| 143 | 143 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 144 | 144 | let container = try decoder.singleValueContainer() |
| 145 | - let dateStr = try container.decode(String.self) | |
| 145 | + let dateStr = try container.decode(String.self).uppercased() | |
| 146 | 146 | |
| 147 | 147 | let formatter = DateFormatter() |
| 148 | 148 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/schema-constraints.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -59,7 +59,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 59 | 59 | let decoder = JSONDecoder() |
| 60 | 60 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 61 | 61 | let container = try decoder.singleValueContainer() |
| 62 | - let dateStr = try container.decode(String.self) | |
| 62 | + let dateStr = try container.decode(String.self).uppercased() | |
| 63 | 63 | |
| 64 | 64 | let formatter = DateFormatter() |
| 65 | 65 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/simple-ref.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -61,7 +61,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 61 | 61 | let decoder = JSONDecoder() |
| 62 | 62 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 63 | 63 | let container = try decoder.singleValueContainer() |
| 64 | - let dateStr = try container.decode(String.self) | |
| 64 | + let dateStr = try container.decode(String.self).uppercased() | |
| 65 | 65 | |
| 66 | 66 | let formatter = DateFormatter() |
| 67 | 67 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/strict-optional.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -55,7 +55,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 55 | 55 | let decoder = JSONDecoder() |
| 56 | 56 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 57 | 57 | let container = try decoder.singleValueContainer() |
| 58 | - let dateStr = try container.decode(String.self) | |
| 58 | + let dateStr = try container.decode(String.self).uppercased() | |
| 59 | 59 | |
| 60 | 60 | let formatter = DateFormatter() |
| 61 | 61 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/top-level-array.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -86,7 +86,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 86 | 86 | let decoder = JSONDecoder() |
| 87 | 87 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 88 | 88 | let container = try decoder.singleValueContainer() |
| 89 | - let dateStr = try container.decode(String.self) | |
| 89 | + let dateStr = try container.decode(String.self).uppercased() | |
| 90 | 90 | |
| 91 | 91 | let formatter = DateFormatter() |
| 92 | 92 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/top-level-enum.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -17,7 +17,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 17 | 17 | let decoder = JSONDecoder() |
| 18 | 18 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 19 | 19 | let container = try decoder.singleValueContainer() |
| 20 | - let dateStr = try container.decode(String.self) | |
| 20 | + let dateStr = try container.decode(String.self).uppercased() | |
| 21 | 21 | |
| 22 | 22 | let formatter = DateFormatter() |
| 23 | 23 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/top-level-primitive-array.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -37,7 +37,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 37 | 37 | let decoder = JSONDecoder() |
| 38 | 38 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 39 | 39 | let container = try decoder.singleValueContainer() |
| 40 | - let dateStr = try container.decode(String.self) | |
| 40 | + let dateStr = try container.decode(String.self).uppercased() | |
| 41 | 41 | |
| 42 | 42 | let formatter = DateFormatter() |
| 43 | 43 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/top-level-primitive.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -12,7 +12,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 12 | 12 | let decoder = JSONDecoder() |
| 13 | 13 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 14 | 14 | let container = try decoder.singleValueContainer() |
| 15 | - let dateStr = try container.decode(String.self) | |
| 15 | + let dateStr = try container.decode(String.self).uppercased() | |
| 16 | 16 | |
| 17 | 17 | let formatter = DateFormatter() |
| 18 | 18 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/tuple.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -83,7 +83,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 83 | 83 | let decoder = JSONDecoder() |
| 84 | 84 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 85 | 85 | let container = try decoder.singleValueContainer() |
| 86 | - let dateStr = try container.decode(String.self) | |
| 86 | + let dateStr = try container.decode(String.self).uppercased() | |
| 87 | 87 | |
| 88 | 88 | let formatter = DateFormatter() |
| 89 | 89 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/unevaluated-properties.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -261,7 +261,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 261 | 261 | let decoder = JSONDecoder() |
| 262 | 262 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 263 | 263 | let container = try decoder.singleValueContainer() |
| 264 | - let dateStr = try container.decode(String.self) | |
| 264 | + let dateStr = try container.decode(String.self).uppercased() | |
| 265 | 265 | |
| 266 | 266 | let formatter = DateFormatter() |
| 267 | 267 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/unicode-codepoint-length.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -63,7 +63,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 63 | 63 | let decoder = JSONDecoder() |
| 64 | 64 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 65 | 65 | let container = try decoder.singleValueContainer() |
| 66 | - let dateStr = try container.decode(String.self) | |
| 66 | + let dateStr = try container.decode(String.self).uppercased() | |
| 67 | 67 | |
| 68 | 68 | let formatter = DateFormatter() |
| 69 | 69 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/union-int-double.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -90,7 +90,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 90 | 90 | let decoder = JSONDecoder() |
| 91 | 91 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 92 | 92 | let container = try decoder.singleValueContainer() |
| 93 | - let dateStr = try container.decode(String.self) | |
| 93 | + let dateStr = try container.decode(String.self).uppercased() | |
| 94 | 94 | |
| 95 | 95 | let formatter = DateFormatter() |
| 96 | 96 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/union-list.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -127,7 +127,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 127 | 127 | let decoder = JSONDecoder() |
| 128 | 128 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 129 | 129 | let container = try decoder.singleValueContainer() |
| 130 | - let dateStr = try container.decode(String.self) | |
| 130 | + let dateStr = try container.decode(String.self).uppercased() | |
| 131 | 131 | |
| 132 | 132 | let formatter = DateFormatter() |
| 133 | 133 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/union.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -90,7 +90,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 90 | 90 | let decoder = JSONDecoder() |
| 91 | 91 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 92 | 92 | let container = try decoder.singleValueContainer() |
| 93 | - let dateStr = try container.decode(String.self) | |
| 93 | + let dateStr = try container.decode(String.self).uppercased() | |
| 94 | 94 | |
| 95 | 95 | let formatter = DateFormatter() |
| 96 | 96 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/uuid.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -107,7 +107,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 107 | 107 | let decoder = JSONDecoder() |
| 108 | 108 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 109 | 109 | let container = try decoder.singleValueContainer() |
| 110 | - let dateStr = try container.decode(String.self) | |
| 110 | + let dateStr = try container.decode(String.self).uppercased() | |
| 111 | 111 | |
| 112 | 112 | let formatter = DateFormatter() |
| 113 | 113 | formatter.calendar = Calendar(identifier: .iso8601) |
Test case
1 generated file · +1 −1test/inputs/schema/vega-lite.schema
Mschema-swiftdefault / quicktype.swift+1 −1
| @@ -10380,7 +10380,7 @@ func newJSONDecoder() -> JSONDecoder { | ||
| 10380 | 10380 | let decoder = JSONDecoder() |
| 10381 | 10381 | decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in |
| 10382 | 10382 | let container = try decoder.singleValueContainer() |
| 10383 | - let dateStr = try container.decode(String.self) | |
| 10383 | + let dateStr = try container.decode(String.self).uppercased() | |
| 10384 | 10384 | |
| 10385 | 10385 | let formatter = DateFormatter() |
| 10386 | 10386 | formatter.calendar = Calendar(identifier: .iso8601) |
No generated files match these filters.