diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm index 82045d40f..3d77ba7cf 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm @@ -32,7 +32,7 @@ NSDate * _Nullable ParseDateString(NSString * _Nullable dateString) { dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.dateFormat = @"yyyy-MM-dd"; dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; - dateFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"]; + dateFormatter.timeZone = [NSTimeZone localTimeZone]; }); return [dateFormatter dateFromString:dateString]; diff --git a/iphone/Maps/UI/PlacePage/Components/OpeningHoursViewController.swift b/iphone/Maps/UI/PlacePage/Components/OpeningHoursViewController.swift index 8e5b0e769..5d24b6d8f 100644 --- a/iphone/Maps/UI/PlacePage/Components/OpeningHoursViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/OpeningHoursViewController.swift @@ -85,10 +85,27 @@ class OpeningHoursViewController: UIViewController { } if let checkDate = self.openingHoursCheckDate, self.expanded { - let checkDateFormatter = RelativeDateTimeFormatter() - checkDateFormatter.unitsStyle = .spellOut - checkDateFormatter.localizedString(for: checkDate, relativeTo: Date.now) - self.checkDateLabel.text = String(format: L("hours_confirmed_time_ago"), checkDateFormatter.localizedString(for: checkDate, relativeTo: Date.now)) + let dateString: String + + // Check if the date is strictly "Today" or "Yesterday" + if Calendar.current.isDateInToday(checkDate) || Calendar.current.isDateInYesterday(checkDate) { + // Case 1: Today/Yesterday -> Use "today" / "yesterday" + let df = DateFormatter() + df.dateStyle = .medium + df.timeStyle = .none + df.doesRelativeDateFormatting = true + + let rawString = df.string(from: checkDate) + // Lowercase first letter: "Today" -> "today" + dateString = rawString.prefix(1).lowercased() + rawString.dropFirst() + } else { + // Case 2: Older -> Use "2 years ago" + let rdf = RelativeDateTimeFormatter() + rdf.unitsStyle = .spellOut + dateString = rdf.localizedString(for: checkDate, relativeTo: Date()) + } + + self.checkDateLabel.text = String(format: L("hours_confirmed_time_ago"), dateString) NSLayoutConstraint.activate([self.checkDateLabelTopLayoutConstraint]) NSLayoutConstraint.activate([self.checkDateLabelBottomLayoutConstraint]) diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift index f025dd373..6072ea8e7 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift @@ -458,11 +458,28 @@ class PlacePageInfoViewController: UIViewController { setupOpenWithAppView() if let checkDate = placePageInfoData.checkDate { - let checkDateFormatter = RelativeDateTimeFormatter() - checkDateFormatter.unitsStyle = .spellOut - checkDateFormatter.localizedString(for: checkDate, relativeTo: Date.now) - self.checkDateLabel.text = String(format: L("existence_confirmed_time_ago"), checkDateFormatter.localizedString(for: checkDate, relativeTo: Date.now)) - checkDateLabel.isHidden = false + let dateString: String + + // Check if the date is strictly "Today" or "Yesterday" + if Calendar.current.isDateInToday(checkDate) || Calendar.current.isDateInYesterday(checkDate) { + // Case 1: Today/Yesterday -> Use "today" / "yesterday" + let df = DateFormatter() + df.dateStyle = .medium + df.timeStyle = .none + df.doesRelativeDateFormatting = true // Generates "Today" + + let rawString = df.string(from: checkDate) + // Lowercase first letter: "Today" -> "today" + dateString = rawString.prefix(1).lowercased() + rawString.dropFirst() + } else { + // Case 2: Older -> Use "2 years ago" + let rdf = RelativeDateTimeFormatter() + rdf.unitsStyle = .spellOut + dateString = rdf.localizedString(for: checkDate, relativeTo: Date()) + } + + self.checkDateLabel.text = String(format: L("existence_confirmed_time_ago"), dateString) + checkDateLabel.isHidden = false NSLayoutConstraint.activate([checkDateLabelLayoutConstraint]) } else { checkDateLabel.text = String()