How to count the days Starting from current date? - flutter

I want to create a day counter inside my app. How display a real-time day counter means the user can see when every second, minute, hours and day changes. And if the user decides to stop the counter, I want to store the total number of days the counter counts.
I have got the flutter package, which is a day countdown package. What they did is accept the end date and count down, but I want the reverse, which means count up the day starting from DateTime.now() until the user stops it.

There are two possible approaches you can take...
The Timer class
or AnimationBuiler
check this repo for an example
https://github.com/John-Daniels/flutter_countdown_app

Related

Get timeline entry and template used for active complication?

I'd like to conditionally reload my active complication in the requestedUpdateDidBegin function or actually tell ClockKit to set the next check 15 minutes before the end of the current timeline entry, but how can I do that without knowing what's in the current complication?
Here's what I'm trying to do:
if let complications = CLKComplicationServer.sharedInstance().activeComplications {
for item in complications {
// Get timeline entry and template used?
}
}
For the current complication, I can only get the family, but no other info like timeline date or template used. Is there a way to get this?
The complication server requests data from your complication controller, but it's not designed to provide its timeline data to you. All you can find out from the server are the earliest and latest time travel dates.
You'd have to get timeline details from the original data you used to create the timeline entries in the first place.
As for scheduling your update 15 minutes before the end of the last entry, you can very easily schedule that as part of the previous reload request. The very last thing the complication server requests (after reloading or extending the timeline) is the next update date.
Since the complication server has just asked you for the future timeline entries in getTimelineEntriesForComplication:afterDate:, you can make note of the last timeline entry's date, offset it by 15 minutes, then return that new date once getNextRequestedUpdateDateWithHandler momentarily gets called.

How to find the date healthkit began receiving input with Swift

I have a function that takes the step data for every day until a point, which is yet to be determined. What I need is a way to determine the day that HealthKit began receiving step count input. I tried to have it repeat until it detects 3 days of zero activity, but that seems too unspecific. Is there an object for the start date?
I don't think that there is an object for the start date readily available, as far as I know.
One solution could be to pull all the data using a HKStatisticsCollectionQuery by day without any predicate ordered by the date, and the first date in the results should be the start date.
Hope this helps.

How I can see tasks done on a particular day?

In Org-mode agenda-view, how I can list tasks which are done on a particular day?
I like to get view for a day or week In the case of larger context of time, I like to have total number of task displayed.

Change the hour when org-mode is starting new day

I use org-mode to clock my work and sometimes I work past midnight for few hours.
So, for example, I clocked time starting 03.06.2013 10pm and ending 04.06.2013 2am.
And org-mode is dividing it at 0am, starting new day. But it would be more convinient for me if that time 0am-2am was recorded for 03.06.2013 instead of 04.06.2013.
So I want to be able to specify at what time (say, 4am) org-mode is deciding the new day has started.
I can use a workaround by shifting timezone for the emacs process, but then I need to keep in mind that all recorded time is shifted... Not very convinient.
See the variable org-extend-today-until, a variable defined in org.el.
Documentation:
The hour when your day really ends. Must be an integer.
This has influence for the following applications:
When switching the agenda to "today". It it is still earlier than
the time given here, the day recognized as TODAY is actually yesterday.
When a date is read from the user and it is still before the time given
here, the current date and time will be assumed to be yesterday, 23:59.
Also, timestamps inserted in capture templates follow this rule.

Exact time at which an event occurred

What i want to do is record the time of when a button has been pressed. All these times will be stored in an array. The program will then run through the array and look at the time values and then highlight the button states at those particular times during playback.
Hopefully this makes sense, whats the best way to do this?! Thanks in advance.
------------------ MORE DETAIL ------------------
the first thing that came up on my mind was... 'ah ha, timestamp', but then looking into the documentation, in a certain section in the timestamp page somewhere in the paragraph it states the following:
....You should not use it to determine the exact time at which the event occurred but should instead compare it to the timestamp of another acceleration event to determine the elapsed time between the events....
this is not great.. as i am assuming that it will not be accurate when it comes to playback of highlighting the buttons at the exact times of when the user had actually pressed them during record.
Please let me know of what i should use and do.
The -[UIEvent timestamp] property will be the most accurate representation of when the touch actually occurred. If you use CFAbsoluteTimeGetCurrent() or the UNIX time() functions you will get the current time the moment function is called, not when the event actually occurred (which will be sometime earlier).
You can use CFAbsoluteTimeGetCurrent() to get the current time expressed as the number of seconds (as a double value, so fractional seconds will be there) since January 1, 2001 00:00:00 GMT.
Hence, you should record the value of CFAbsoluteTimeGetCurrent() at some point when your app starts, and then record its value every time a button is pressed. Then, by subtracting the time the app started from the time the button was pressed gives you the number of seconds the button was pressed since the app started. You can then play back the button presses at a later time by taking that time delta and adding it to the time when playback started.