What values should the variables StartTime and EndTime be set to, so that the session runs perpetually.
I do not have a specific EndTime, and would like the session to keep running.
To have a session that will never reset you need to use the setting NonStopSession=Y
Actually the config page mentions that this is the same as setting StartTime and EndTime both to 00:00:00. However, if I recall correctly the session will reset at 00:00:00 nevertheless (contrary to what the doc says).
I haven't done this myself, but could you try with a combination of Weekdays and setting StartTime > EndTime?
From QuickFIX/J configuration on Weekdays:
For daily sessions that are active on specific days of the week.
Use in combination with StartTime and EndTime.
Incompatible with StartDay and EndDay.
If StartTime is before EndTime then the day corresponds to the StartTime.
It is also possible that just omitting StartTime and EndTime completely from your configuration does what you want. As I said, I never tried this before.
Related
Problem
I need to get a callback when at least X amount of time has passed since the date for the callback has been set.
Example 1:
This would have worked great, but it's possible to trigger an execution of the block by setting the date earlier than the correct time right now:
let responseDate = Date().advanced(by: 60) // 1 min
OperationQueue.current.schedule(after: .init(responseDate), {
print("the time is now!") // possible to set the current date 1 min before
}
On the other hand, the solution for getting a current uptime from this answer works great, but it requires timer constantly running to check if we're close to date.
Is it possible to combine these two approaches and somehow "attach" a callback to KERN_BOOTTIME, so that the OS will call my method when the boottime reaches a certain value?
I'm looking as well to alternative engineering solutions that satisfy two criterias:
It should not be possible to trigger the callback by resetting the device date to some arbitrary value in the past
If the device has been put to sleep (e.g. by pressing the on/off side button), the clock should still be "ticking", so that the method will be called back while the app is running in the background.
More details:
Backgrounding / app termination is out of scope
The main point is to prevent a bypass by switching the date backwards in the settings.
In core motion, data is returned in a class inheriting from CMLogItem, which has a timestamp property. The timestamp is a TimeInterval that is the time since the device booted.
How do I get when the device booted?
From the comments, I was able to find ProcessInfo.processInfo.systemUptime which is the time since last boot. From this, and Date(), I can get the time of start via:
time_of_last_boot = Date() - ProcessInfo.processInfo.systemUptime
I want to check if the current time (24 hours or 12 hours am/pm) has just passed 12 o'clock.
I did something like that in a view, but in this case I checked if it was not yet 12 in the morning:
let date = Date()
let calendar = Calendar.current
let hora = calendar.component(.hour, from: date)
let minutos = calendar.component(.minute, from: date)
if hora < 12 && minutos <= 59 { ... }
I don't know if I explained it well... I was wondering if I can check if the time has passed in AppDelegate, always in background, and execute a function when 12 am has passed. It is possible?
I don't think you will achieve at least in iOS framework.
Apple won't allow you to execute code at a certain time interval in background. Because it's almost similar what some malwares do.
Additional: But if you don't want to execute code in background rather when in your app's foreground then it's possible using timer.
Depending on what you're trying to do, Local Notifications might be of use to you:
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/SchedulingandHandlingLocalNotifications.html#//apple_ref/doc/uid/TP40008194-CH5-SW1
You can schedule them and they will be delivered to the user even when your app is in the background or not running. The user may then launch your app with a particular action on the notification.
When making multiple calls to the YouTube API method player.loadVideoById() with the same videoId and different startSeconds, the video will continue to start from the startSeconds time first specified.
For example, if I run player.loadVideoById({videoId:vID, startSeconds:startTime}) the video will load and play from startTime as requested. However, if I execute this statement again and change the startTime parameter, the video will load from the startTime I first specified. I have run this command manually with no variables for the vID and the startTime so I can rule out the idea that my input variables simply aren't changing.
Anyone else have this problem?
I want to use NSDate and NSTimer to retrieve the elapsed time between I press a start button and a stop button and present the time in seconds. Then I want to use the time for a calculation. I know how to get the time but it is always in format like this 2013-01-15 14:01:55.369.
How do I subtract one time from the other to get the seconds.
I am not sure how to use NDDate and NSTimer.
This should be really easy but I am sort of stuck here.
//Make two properties `NSDate *startDate, *endDate`
//in the action method of start Button
startDate=[NSDate date];
//in the action method of stop Button
stopDate=[NSDate date];
long elapsedSeconds=[stopDate timeIntervalSinceDate:startDate];
NSLog(#"Elaped seconds:%ld seconds",elapsedSeconds);
Please check my project for stopwatch kind of thing, this may come handy for you
Check this code, most of requirement are solved here.
You can use
- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)date
to get the time interval between the receiver and a given date in seconds.
To get current time from NSData use:
[[NSData data] timeIntervalSince1970];
and just substract it from your NSTime value.
Use timeIntervalSinceDate between the start date and en stop date.