how to convert the player current time to seconds - macos

i want to convert AVPlayer current to minutes and seconds.
Please suggest me how to convert Player Current time to minutes and seconds
when i gone through the documentation of avplayer,i came to know that it returns cmtime

Check Apple's documentation for CMTime: CMTime Reference.
value divided by timescale equals seconds.

Related

Google Spreadsheet time between date - hour calculation

I am at a loss, i looked around the internet and stackoverflow but every so called solution is giving either errors or plainly don't work.
I have the following setup.
4 fields (setup in date dd-mm-yyyy, hour hh:mm:ss) seconds are not important.
start date : 7-1-2020
start hour : 23:30:00
end date : 8-1-2020
end hour : 03:50:00
What i want to happen is to calculate the diffrence in 'hours, minutes' between the end and the start date, hour. But when I calculate and change the end date to lets say 09-01-2020 it does not count the extra 24h at all.
Use Text format:
=text(A3-A1+A4-A2,"[H]:MM")
You need to format the time difference as a duration using the custom format
[h]:mm
for hours and minutes
or
[h]
for whole hours.
There are some good notes on how it works in Excel here and as far as I can tell from testing it Google Sheets is the same.
Alternatively, if I read your question as wanting to drop the minutes and seconds from the times before doing the calculation, you could use
=(B3-B1)*24+hour(B4)-hour(B2)
and just format the result as a normal number.
After alot of fiddeling and this post i came to the conclusion that the main issue was not laying within the mathematical but within the format of the cell.
By default all time values in sheets are 24h max.
So the basic formula =start - end
The time format needed should be
more date time format
elapsed hours : elapsed minutes
apply
Now you should see the correct elapsed hours and minutes

Is it possible to know the current time in the interval of an NSTimer?

I have an NSTimer with a time interval set to 10 seconds with repeats.
I have a scenario where I'm starting the timer, and let's say that after 15 seconds I want to check the interval of the timer. I expect to get the value 5.
Is this kind of thing possible?
NSTimer has a property fireDate which contains an NSDate object representing the next absolute date the timer fires.
timer.fireDate.timeIntervalSinceDate(NSDate())
returns the difference from now to the next fire date as NSTimeInterval

Logic for tracking hours worked

I was wanting to write a program in C that I can simply type in the hours that I worked for each day of the week, including time on break, that will take my input and return the total number of hours I have worked for that week. It's dumb, I know, but I am not sure how to do the math for this regarding time on the clock.
Thank you
At beginning of work: get the current date, make it into seconds.
At end of work: get the current date, make it into seconds.
So working seconds = end seconds - beginning seconds
Then you'll just have to make those into hours.

ROR + Increase Time Stamp By One Hour

Here, My timestamps code for Ruby is
#{Time.now.utc.strftime("%B #{ActiveSupport::Inflector.ordinalize(Time.now.day)}%Y%R")}".
Now I want to increase my hour by one. So how it can be possible ?
If I understand correctly you can add one hour and then format them to your previous format:
(Time.now+1.hour).utc.strftime("%B #{ActiveSupport::Inflector.ordinalize(Time.now.day)}%Y%R")

Can i get a notification, when a new day begins?

In Cocoa, is there a notification i can register for, that informs me, when a new day begins - at 00h:00min:01s in the morning?
If it is for iPhone development, you can also listen for a UIApplicationSignificantTimeChangeNotification. It gets posted on more occasions than the arrival of midnight, but when you receive one, you can simply check if you are on or near midnight.
For Mac OS X, you would have to do what Tom Dalling suggests but you should also keep track of changes to the system clock yourself (in order to update your timer) as well as changes to the current time zone.
There's no notification that I know of. You can get a timer to fire whenever a new day begins like so:
[[NSTimer alloc] initWithFireDate:midnight
interval:60 * 60 * 24 //one day, in seconds
target:someObj
selector:#selector(someSelector)
userInfo:nil
repeats:YES];
The trick is getting an NSDate set to midnight. Check the Date and Time Programming Guide for how to do that with date components and the like.
EDIT: see this question for how to get the midnight NSDate.
As of iOS8, you can also directly listen to NSCalendarDayChangedNotification.
As mentioned by others, in iOS 8 you can use NSCalendarDayChangedNotification. In terms of how to do that, this post gives you more info.
Essentially NSCalendarDayChangedNotification requires that you go to your appDelegate file and insert the below code in app (adapted from guide for Swift 3):
NotificationCenter.default.addObserver(self, selector: #selector(ViewController.dayChangedOperations(notif:)), name:NSNotification.Name.NSCalendarDayChanged, object:nil)
Where "ViewController" is the classname of one of my classes and "dayChangedOperations" is the name of the function that I want to run whenever the day changes.
Count Days Since Last Change
Note that all you get from this is an alert that the day changed. You are not given the number of days since the app last ran. So remember to save the date to a userDefault each time this function runs, so you can use it for comparison later.

Resources