Here's one way to get the date for the last day of the current week using Swift:
main.swift457 chars15 lines
This code uses the Calendar.current
instance to get the start of the current week using dateInterval(of:interval:start:for:)
. It then sets the end of the week to be 6 days after the start using date(byAdding:value:to:)
. Finally, it checks that the end of the week is not in the future using min(:_)
and prints the result.
gistlibby LogSnag