Format date and time but exclude "today date" in Swift?

My code: let dateFormatter = DateFormatter() dateFormatter.timeStyle = .short dateFormatter.dateStyle = .short dateFormatter.locale = .current lblDateTime.text = dateFormatter.string(from: date) The problem is I need dateFormatter.dateStyle = .none for today date. How to resolve it correctly? Is it possible to avoid manual date calculations to determine "today date"? >Solution : You can check if the given… Read More Format date and time but exclude "today date" in Swift?

wrong time and resolution axis when plotting time series (secs instead of min)

I want to plot a DataFrame as a time series import matplotlib.pyplot as plt plt.plot(df[‘time’],df[‘Power’]) or df2 = df.set_index(‘time’) df2.Power.plot() which both show all 3531 y values correctly but wrong x axis time labels, like 25 seconds instead of 25 minutes. timestamps are not completely regular and have ms decimals 0 2022-05-16 19:59:25.690 1 2022-05-16… Read More wrong time and resolution axis when plotting time series (secs instead of min)

Swift Dateformatter() converts wrong date

I want to convert a string into a date and use a small function. If I run the code the results is different from the input: let startDateString = "20-02-2022-15-00" print(startDateString) let dateFormatter = DateFormatter() dateFormatter.dateFormat = "DD-MM-YYYY-HH:mm" dateFormatter.timeZone = TimeZone.current let startDate = dateFormatter.date(from: startDateString) print(startDate!) the startDateString is "20-02-2022-15-00" the result of startDate… Read More Swift Dateformatter() converts wrong date

Why am I getting timezone differences when converting date and getting current date?

In the following code example: func numberOfDaysBetween(toDate: String) -> Int { // toDate = "2021/12/21" let dateFormatter = DateFormatter() dateFormatter.timeZone = TimeZone.current dateFormatter.dateFormat = "yyyy/MM/dd" let currentDate = Date() let toDateFormatted = dateFormatter.date(from: toDate) print ("Current Date: \(currentDate)") // Current Date: 2021-12-21 11:50:12 +0000 print ("ToDate: \(toDate)") // ToDate: 2021/12/21 print ("ToDateFormatted: \(toDateFormatted)") // ToDateFormatted:… Read More Why am I getting timezone differences when converting date and getting current date?