You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PlaceDetails placeDetails = ... /* get it from the api */;
OpeningHoursPeriod openingHoursPeriod = placeDetails.openingHours.periods.first;
DateTime wrongDateTime = openingHoursPeriod.open.toDateTime();
Will return a DateTime object which has it's day shifted one day to the future.
The text was updated successfully, but these errors were encountered:
DateTime dayTimeToDateTime(int day, String time) {
if (time.length < 4) {
throw ArgumentError(
"'time' is not a valid string. It must be four integers.");
}
final _now = DateTime.now();
// Maps is 0-index DO^W
final _weekday = _now.weekday - 1;
final _mondayOfThisWeek = _now.day - _weekday;
final _computedWeekday = _mondayOfThisWeek + day;
final _hour = int.parse(time.substring(0, 2));
final _minute = int.parse(time.substring(2));
return DateTime.utc(_now.year, _now.month, _computedWeekday, _hour, _minute);
}
to this:
DateTime dayTimeToDateTime(int day, String time) {
if (time.length < 4) {
throw ArgumentError(
"'time' is not a valid string. It must be four integers.");
}
final _now = DateTime.now();
// Maps is 0-index DO^W
final _adjustedDay = day == 0 ? 6 : day - 1;
final _weekday = _now.weekday - 1;
final _mondayOfThisWeek = _now.day - _weekday;
final _computedWeekday = _mondayOfThisWeek + _adjustedDay;
final _hour = int.parse(time.substring(0, 2));
final _minute = int.parse(time.substring(2));
return DateTime.utc(_now.year, _now.month, _computedWeekday, _hour, _minute);
}
The method
dayTimeToDateTime
in thesrc/utils.dart
expects the given day parameter to have the following mapping:0 -> Monday
1 -> Tuesday
...
6 -> Sunday
When it actually has the mapping:
0 -> Sunday
1 -> Monday
...
6 -> Saturday
The second mapping is used in the Places API as documented here: https://developers.google.com/maps/documentation/places/web-service/details#PlaceDetailsResults
So currently when running this code:
Will return a
DateTime
object which has it's day shifted one day to the future.The text was updated successfully, but these errors were encountered: