I can not set my date to be updated in widgetKit

Hi, I'm following this article to set my time update in Text field.
https://developer.apple.com/documentation/widgetkit/keeping-a-widget-up-to-date

I tried to wait for long but my time does not update at all. I'm using XCode 12 beta 2.

Is there a bug here?

Further more, is there any way to customize the date format?

Please support, thanks

Replies

In side widget View, I have this code. I tried to run it on iOS 14 device.
 
Code Block
Text(Date(), style: .time)
          .lineLimit(1)
          .minimumScaleFactor(0.3)
          .font(.system(size: 45))

It shows the time, but the time does not get updated realtime like the Apple document said in 'Display Dynamic Dates' sections.

Please help, Apple developer team..



That section of the documentation isn't super clear since it's under the header "Display Dynamic Dates", but it doesn't look like all the date styles are intended to be dynamic and updated in real time. The documentation says that .relative, .offset, and .timer "update automatically," but it says that .date and .time "display an absolute date or time".

Have you tried with .timer or .relative?
I tried timer and relative, they get updated automatically.
But the date or time isn't.
Maybe it's not updated at all. Quite a vague document
The .time and .date styles do not update over time. Using "Text(Date(), style: .time)" will display the time when the widget timeline was refreshed with a call to getTimeline(for:in:completion:) and will remain static until the next time the timeline is regenerated. The relative styles (.relative, .offset, .timer) are special in that they update in real-time between refreshes of the timeline which allows you to show a relative time without having to generate a timeline entry for each change in the value.

As a side note, I will mention that .relative shows the difference in time but without any indication of if it is positive or negative. Exactly 15 minutes before the given time will return "15 min, 0 sec" and exactly 15 minutes after the given time will also return "15 min, 0 sec"