Thank you again for this great tutorial! 19:00 I believe you can check if two dates are in the same day with the following function: Calendar.current.isDate(_ date1: Date, inSameDayAs: Date)
Doesn’t this also mention that the time has to be the same too? A Date has a time so if you are matching two dates it will also compare the time of that date
@@StewartLynch No, it only returns true if the two dates are equal in terms of day (eg. March 12th). print(date1) print(date2) let bool = Calendar.current.isDate(date1, inSameDayAs: date2) print(bool) Output 1: 2024-03-13 19:23:00 +0000 2024-03-12 19:23:15 +0000 false Output 2: 2024-03-12 15:23:00 +0000 2024-03-12 19:23:15 +0000 true
Thanks for the video. I watch Sean also. I noticed when I add it to my app and view on my phone the Sun - Sat are all bunched together and you cant read.. What did I miss? Almost like it is to big for my screen
@@markgeorge4202 I am not sure that you can get that level of granularity with the formatted options. I could be wrong, but I stuck with what I was most familiar with. I will have to explore the formatted option more. Would love to see what you come up with as an alternative though if you care to share.
Thank you so much for brining this to my attention. I have updated the source code for the completed project (link in the description). I have updated the Date+Extension to accommodate for different weekday starts.
Great video @stewart I am getting the following error with XCODE 15.4 "Static method 'buildExpression' requires that 'Text' conform to 'TableRowContent'". This error appears after "if day.monthInt != date.monthInt { Texr("")". Can you or anyone help me fix this error?
@@StewartLynch no sir I do not. However even if I copy your text into my files I still get the error. I seem to be getting it when I ad in the current date display. I remove 'Date.now.startOfDay == day.startOfDay ? .red.opacity(0.3) :' and everything works except the current date.
Thanks for the video Stewart, i have an anomaly when using a start of week other than a sunday, if i set monday as a start day, scrolling along to September, or October 2024 misses the first day of the month from the view. I think it's coming from this function: var firstWeekDayBeforeStart: Date startOfMonthWeekday - Self.firstDayOfWeek causes issues if startOfMonthWeekday is less than Self.firstDayOfWeek. I've amended my version to: let numberFromPreviousMonth = startOfMonthWeekday < Self.firstDayOfWeek ? (startOfMonthWeekday + 7) - Self.firstDayOfWeek : startOfMonthWeekday - Self.firstDayOfWeek This works for any week day start , thanks for the inspiration
Your date helpers should be 6 lines, not 17: static var capitalizedFirstLettersOfWeekdays: [String] { Calendar.current.veryShortStandaloneWeekdaySymbols } static var fullMonthNames: [String] { Calendar.current.monthSymbols } Typical ChatGPT being a blabbermouth.
Great content, this is exactly what I was looking to learn how to do
Fantastic, thanks to you and Sean for this.
Awesome lessons Stewart… 🔥💯 thank you
Great tutorial! Looking forward to the next one.
Thank you again for this great tutorial!
19:00 I believe you can check if two dates are in the same day with the following function:
Calendar.current.isDate(_ date1: Date, inSameDayAs: Date)
Doesn’t this also mention that the time has to be the same too? A Date has a time so if you are matching two dates it will also compare the time of that date
@@StewartLynch No, it only returns true if the two dates are equal in terms of day (eg. March 12th).
print(date1)
print(date2)
let bool = Calendar.current.isDate(date1, inSameDayAs: date2)
print(bool)
Output 1:
2024-03-13 19:23:00 +0000
2024-03-12 19:23:15 +0000
false
Output 2:
2024-03-12 15:23:00 +0000
2024-03-12 19:23:15 +0000
true
@@drmucahiderdogan Excellent. Good to know. Thanks for sharing
@@StewartLynch We thank you for sharing these great content. 🙏🏻
Excellent Stewart. Thanks!
Thank you Stewart, great tutorial!
I just noticed for June 29, 2024 and 30, 2024 this is not displaying the counts. Have you noticed this?
I will have to check
@@StewartLynch It is actually on your other one where you added setupCounts - Trying to debug now to see if I can figure it out
It is a dumb error on my part. I will pin a comment with the fix
@@StewartLynch You rock.. Was not expecting a response so quickly
Thanks for the video. I watch Sean also. I noticed when I add it to my app and view on my phone the Sun - Sat are all bunched together and you cant read.. What did I miss? Almost like it is to big for my screen
No idea. Can you compare to the source code?
I copied and pasted from your project only added a zstack- to change the background- let me debug some more.
Why didn't you use the new Date.formatted()?
At what point of the video are you referring to
4:59, when defining fullMonthNames@@StewartLynch
at 4:59@@StewartLynch
@@markgeorge4202 I am not sure that you can get that level of granularity with the formatted options. I could be wrong, but I stuck with what I was most familiar with. I will have to explore the formatted option more. Would love to see what you come up with as an alternative though if you care to share.
how can i have the week start at Monday instead of sunday
Thank you so much for brining this to my attention. I have updated the source code for the completed project (link in the description). I have updated the Date+Extension to accommodate for different weekday starts.
@@StewartLynchperfect thank you so much
When are you going over the basics like $ bindings, \.self etc. I’m a beginner to SwiftUI!!
You might want to check out my video on that topic th-cam.com/video/EuAGDhJpUN0/w-d-xo.html
Great video @stewart I am getting the following error with XCODE 15.4 "Static method 'buildExpression' requires that 'Text' conform to 'TableRowContent'". This error appears after "if day.monthInt != date.monthInt { Texr("")". Can you or anyone help me fix this error?
Do you see that with my code?
@@StewartLynch no sir I do not. However even if I copy your text into my files I still get the error. I seem to be getting it when I ad in the current date display. I remove 'Date.now.startOfDay == day.startOfDay ? .red.opacity(0.3) :' and everything works except the current date.
🫶🫶
Thanks for the video Stewart, i have an anomaly when using a start of week other than a sunday, if i set monday as a start day, scrolling along to September, or October 2024 misses the first day of the month from the view.
I think it's coming from this function: var firstWeekDayBeforeStart: Date
startOfMonthWeekday - Self.firstDayOfWeek causes issues if startOfMonthWeekday is less than Self.firstDayOfWeek.
I've amended my version to:
let numberFromPreviousMonth = startOfMonthWeekday < Self.firstDayOfWeek ? (startOfMonthWeekday + 7) - Self.firstDayOfWeek : startOfMonthWeekday - Self.firstDayOfWeek
This works for any week day start , thanks for the inspiration
I believe my final source code also has fixed this issue.
Your date helpers should be 6 lines, not 17:
static var capitalizedFirstLettersOfWeekdays: [String] { Calendar.current.veryShortStandaloneWeekdaySymbols
}
static var fullMonthNames: [String] { Calendar.current.monthSymbols
}
Typical ChatGPT being a blabbermouth.
Whatever works for you, Thanks for your contribution.