Skip to content

Commit 1220ac5

Browse files
committed
Simplify date formatting
1 parent 7b45174 commit 1220ac5

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

WooCommerce/Classes/ViewModels/Booking Details/AppointmentDetailsContent.swift

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,6 @@ import struct Networking.Booking
33

44
extension BookingDetailsViewModel {
55
struct AppointmentDetailsContent {
6-
static let appointmentDateFormatter = {
7-
let dateFormatter = DateFormatter()
8-
dateFormatter.dateFormat = "EEEE, dd MMMM yyyy"
9-
return dateFormatter
10-
}()
11-
12-
static let appointmentTimeFrameFormatter = {
13-
let dateFormatter = DateFormatter()
14-
dateFormatter.dateFormat = "hh:mm a"
15-
return dateFormatter
16-
}()
17-
186
struct Row: Identifiable {
197
let title: String
208
let value: String
@@ -28,10 +16,10 @@ extension BookingDetailsViewModel {
2816

2917
init(_ booking: Booking) {
3018
let durationMinutes = Int(booking.endDate.timeIntervalSince(booking.startDate) / 60)
31-
let appointmentDate = Self.appointmentDateFormatter.string(from: booking.startDate)
19+
let appointmentDate = booking.startDate.formatted(date: .numeric, time: .omitted)
3220
let appointmentTimeFrame = [
33-
Self.appointmentTimeFrameFormatter.string(from: booking.startDate),
34-
Self.appointmentTimeFrameFormatter.string(from: booking.endDate)
21+
booking.startDate.formatted(date: .omitted, time: .shortened),
22+
booking.endDate.formatted(date: .omitted, time: .shortened)
3523
].joined(separator: " - ")
3624

3725
rows = [

WooCommerce/Classes/ViewModels/Booking Details/HeaderContent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension BookingDetailsViewModel {
1515
let status: [Status]
1616

1717
init(_ booking: Booking) {
18-
bookingDate = Self.dateFormatter.string(from: booking.startDate)
18+
bookingDate = booking.startDate.formatted(date: .numeric, time: .omitted)
1919
serviceName = "Women's Haircut"
2020
customerName = "Margarita Nikolaevna"
2121
status = [.paid, .booked]

0 commit comments

Comments
 (0)