Skip to content

Commit 6611ae6

Browse files
[dart] fix Date.toDateTime utc (#9717)
1 parent 9999494 commit 6611ae6

File tree

2 files changed

+8
-6
lines changed
  • modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value
  • samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model

2 files changed

+8
-6
lines changed

modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/date.mustache

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ class Date implements Comparable<Date> {
2424
/// Convert to a [DateTime].
2525
DateTime toDateTime({bool utc = false}) {
2626
if (utc) {
27-
DateTime.utc(year, month, day);
27+
return DateTime.utc(year, month, day);
28+
} else {
29+
return DateTime(year, month, day);
2830
}
29-
return DateTime(year, month, day);
3031
}
3132

3233
@override
@@ -66,4 +67,4 @@ class Date implements Comparable<Date> {
6667

6768
extension DateTimeToDate on DateTime {
6869
Date toDate() => Date(year, month, day);
69-
}
70+
}

samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/date.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ class Date implements Comparable<Date> {
2424
/// Convert to a [DateTime].
2525
DateTime toDateTime({bool utc = false}) {
2626
if (utc) {
27-
DateTime.utc(year, month, day);
27+
return DateTime.utc(year, month, day);
28+
} else {
29+
return DateTime(year, month, day);
2830
}
29-
return DateTime(year, month, day);
3031
}
3132

3233
@override
@@ -66,4 +67,4 @@ class Date implements Comparable<Date> {
6667

6768
extension DateTimeToDate on DateTime {
6869
Date toDate() => Date(year, month, day);
69-
}
70+
}

0 commit comments

Comments
 (0)