Search results for

calendar

1,863 results found

Post

Replies

Boosts

Views

Activity

Reply to Calendar nextDate/enumerateDates methods with backward direction does not work for September
I just tested with other time zones and the results are different... For some time zones, the result is correct, for others, not. I used the following code to print the result for all time zones. Optional(1970-08-31 23:00:00 +0000) for Europe/London Optional(1995-08-31 23:00:00 +0000) for Europe/Paris Optional(2002-08-31 22:00:00 +0000) for Europe/Vilnius Optional(2023-09-01 07:00:00 +0000) for America/Los_Angeles for zone in TimeZone.knownTimeZoneIdentifiers { var calendar: Calendar = Calendar(identifier: .gregorian) calendar.timeZone = TimeZone(identifier: zone) ?? .autoupdatingCurrent let matchingDateComponents: DateComponents = DateComponents(month: 9) let date: Date? = calendar.nextDate( after: Date.now, matching: matchingDateComponents, matchingPolicy: .nextTime, direction: .backward ) print(zone, date) }
Topic: App & System Services SubTopic: General Tags:
Dec ’23
Calling an URSession task in background and display local notification
I would like to call a GetMessages API every 10 minutes while the app is not active or shutdown. if a message is returned, display the message as a local notification Will the background api run if the app is shut down? An example of this is when an email app shows a notification. Can they pull from their server while the app is not running or do they use the push notification service. I know that calendar events can be scheduled locally and for location changes, but I don't know if calling a api task with the app not running is possible.
1
0
743
Dec ’23
In Swift, how can I get the "last Sunday of a month before the current date"?
I want to find the last Sunday of a month before the current date in Swift, but using the Calendar nextDate function doesn't work (always returns nil). var calendar: Calendar = Calendar(identifier: .gregorian) calendar.timeZone = .gmt let lastSundayDateComponents: DateComponents = DateComponents( weekday: 1, weekdayOrdinal: -1 ) let previousLastSundayDate: Date? = calendar.nextDate( after: Date.now, matching: lastSundayDateComponents, matchingPolicy: .nextTime, repeatedTimePolicy: .first, direction: .backward ) print(previousLastSundayDate ?? Not found) // Not found If I use a positive weekdayOrdinal, it's working normally and the same nextDate method provides the correct date. let firstSundayDateComponents: DateComponents = DateComponents( weekday: 1, weekdayOrdinal: 1 ) When I check if the date components can provide a valid date for the given calendar, it returns false... let lastSundayInNovember2023DateComponents: DateComponents = DateComponents( year: 2023, mo
2
0
1k
Dec ’23
A random crash on DateFormatter
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libicucore.A.dylib 0x18c500918 icu::SimpleDateFormat::subFormat(icu::UnicodeString&, char16_t, int, UDisplayContext, int, char16_t, icu::FieldPositionHandler&, icu::Calendar&, UErrorCode&) const + 532 1 libicucore.A.dylib 0x18c500520 icu::SimpleDateFormat::format(icu::Calendar&, icu::UnicodeString&, icu::FieldPositionHandler&, UErrorCode&) const + 520 2 libicucore.A.dylib 0x18c5002f8 icu::SimpleDateFormat::format(icu::Calendar&, icu::UnicodeString&, icu::FieldPosition&) const + 84 3 libicucore.A.dylib 0x18c42c4ac icu::DateFormat::format(double, icu::UnicodeString&, icu::FieldPosition&) const + 176 4 libicucore.A.dylib 0x18c535c40 udat_format + 352 5 CoreFoundation 0x189349a14 __cficu_udat_format + 68 6 CoreFoundation 0x189349898 CFDateFormatterCreateStringWithAbsoluteTime + 192 7 Foundation 0x18a432bf0 -[NSDateFormatter stringForObjectValue:] + 316 8 ShiningUtiliesKit 0x105
1
0
827
Dec ’23
Background Task scheduling and Date. Should we use absolute or calendar date?
Should we use absolute or calendar Date when scheduling background tasks? I would guess it doesn't matter how we construct Date but I wanted to double check since WWDC videos show both ways. I've experienced some instances where background tasks ran much later than expected, and while this is not surprising since iOS has many factors to consider when they allot background execution time, the times of execution seemed to line up with the hours change between Absolute and Calendar time. Or And I understand there is no guarantee that the system will run the background task exactly or even near the date requested. Thanks!
2
0
976
Dec ’23
Reply to Background Task scheduling and Date. Should we use absolute or calendar date?
The properties you’re working with here are of type Date. A Date value is a floating point offset from the epoch (the start of 2001 GMT) and thus, in your terms, it’s always absolute [1]. How you create that Date value is up to you. If you want to generate it using Calendar, that’s fine. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com [1] I don’t consider it to be absolute because it’s based on the wall clock and thus can change if the device’s time changes, but coming up with words to discuss all these concepts is hard.
Topic: App & System Services SubTopic: Core OS Tags:
Nov ’23
Set 12 vs 24 hour with the new date formatting API in iOS 15
Using the new date formatting API available in iOS 15, I would like to respect the 12 vs 24 hour setting on a user-by-user basis. With DateFormatter it can be done as follows, for example, to force a 24 hour time irrespective of the user locale. let formatter = DateFormatter() formatter.dateFormat = HH:mm // or hh:mm for 12 h However, I cannot figure out how to force the new date formatting API in iOS 15 to do the same thing, i.e. force displaying 12 vs 24 h. I'm using a format style like this: var formatStyle = dateTime formatStyle.calendar = calendar if let timeZone = timeZone { formatStyle.timeZone = timeZone } return formatStyle And applying it like this, for example, for a given Date instance: date.formatted(formatStyle.hour(.defaultDigits(amPM: .abbreviated))) However, this seems to always give a formatted string relevant to the locale, for example, it's always 12h for the US and always 24h for the UK. This is not the behaviour I really need though, and I'd like to allow each individual user to
7
0
11k
Nov ’23
SwiftUI #Preview with Callback Closure
I have created a simple calendar framework of my own. The screenshot below shows what it looks like. The following lines show a concise version of my calendar framework. The deal is such that the app will return a date when I tap a date button with the callBack closure. import SwiftUI struct ContentView: View { @State private var navigateToAddDate = false @State private var days: [Day] = [] @State var callBack: ((Date) -> Void) private let cols = [ GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()) ] var body: some View { NavigationStack { VStack { LazyVGrid(columns: cols) { ForEach(days, id: .self) { day in Button(action: { selectedDay = day navigateToAddDate.toggle() }, label: { Image(systemName: (day.num).circle.fill) .resizable() .aspectRatio(contentMode: .fit) .foregroundColor(day.show ? dateTextForecolor(day: day) : .clear) }) .disabled(day.isInvalid) } } } } } } struct Conte
3
0
1.7k
Nov ’23
Reply to macOS keeps showing "[App] would like to access data from other apps" warning even if accepting it each time
How is your app signed? A problem with the signature might prevent the OS from remembering that permission has been granted before. Thanks for the suggestion, but I don't think there's any problem with the signature. All other warnings (Calendar, Reminders, etc.) only get shown once, but this one gets shown each time. I think it only started appearing since macOS 14 Sonoma.
Topic: App & System Services SubTopic: General Tags:
Nov ’23
Reply to Kernel panic on Macbook Air
Same issue. The same problem. Sometimes at work, but more often while sleeping. panic(cpu 1 caller 0xfffffe001a88ac50): skr.txausd.upipe:533:IDSClientChannelNexusOS: skr 0x0xfffffe24eead1c00 sg 0x0xfffffe24e43edea8 (idx 0) unable to satisfy mandatory allocation Debugger message: panic Memory ID: 0x6 OS release type: User OS version: 23B81 Kernel version: Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:12 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8103 Fileset Kernelcache UUID: 7BF1E8441DE38056EC1FDED67A9F101B Kernel UUID: 24DA617C-1A30-3D13-A4BB-7BF37E60644E Boot session UUID: E59838AD-1CA8-488B-8E0A-392D8116B1BC iBoot version: iBoot-10151.41.12 secure boot?: YES roots installed: 0 Paniclog version: 14 KernelCache slide: 0x0000000011d58000 KernelCache base: 0xfffffe0018d5c000 Kernel slide: 0x0000000011d60000 Kernel text base: 0xfffffe0018d64000 Kernel text exec slide: 0x0000000013264000 Kernel text exec base: 0xfffffe001a268000 mach_absolute_time: 0x16ca94ed494 Epoch Time: sec usec Boot : 0x655864aa 0x000ee
Topic: App & System Services SubTopic: Hardware Tags:
Nov ’23
Reply to When SwiftUI View is Equatable - questions...
∙View can conform to Equatable... True, .equatable() is no longer required, not sure what version that changed in. . ∙When view contains @ObservedObject... False, regardless of the outcome of ==, body is always called when any @Published property of the object changes or objectWillChange is published. . ∙Does view, that is Equatable, need to care about equality of its subviews.. No, a subview will just follow the same algorithm. Best to only init a View with the data it actually needs and uses in its body to keep invalidation tight. . ∙When view returns true on equality check... True, if you returned true from == but had @Environment(.calendar) var calendar and the calendar changed the body would still be called. This is the same behaviour as @ObservedObject in the 2nd question. . ∙When the observed object conforms to Equatable... In my testing the if an ObservedObject conformed to Equatable the == func was never called. My test code: import SwiftUI import Combine struct ViewTest {
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’23