Pebble.js Clock.Weekday function - pebble-watch

So, I don't know if I didn't notice before or what but if I use Clock.weekday and assign a day and hour and minute that are very close to the current date (today or tomorrow) it works. If I assign to a day two days later than the current date it says wakeup failed invalid argument when I try to set up a wakeup with that time (time being var time = Clock.weekday(blah blah)...
Am I doing something wrong? or is there a limit with the clock.weekday function?

There was an issue with how moment was being used. It is has now been fixed on master. Thanks for bringing this up!
Here is the commit with the fix.

Related

How do I create a strategy trigger for a daily trade at a certain time?

I want to test a simple strategy based on time: every day at fixed time check some conditions and go long. every day at fixed time exit.
Whatever I try to get timeOpenCondition I get syntax error.
Tried things similar to:
EntryTime = if hour=0800 and minute=0
ExitTime = if hour=1400 and minute=0
It feels like I don't get the concept of how this works. Appreciate any help!

What is "INTERVAL=0" means in Oracle Schedular?

My Oracle DBA have setup a task with following repeat_interval:
Start Date :"30/JAN/20 08:00AM"
Repeat_interval: "FREQ=DAILY; INTERVAL=0; BYMINUTE=15"
Can I ask what is "Interval=0" means?
Does it means this task will run daily from 8AM, and will repeat every 15 mins until success?
I tried to get the answer from Google, but what I find is what is Interval=1, but nothing for 0.
So would be great if anyone can share me some light here.
Thanks in advance!
INTERVAL is the number of increments of the FREQ value between executions. I believe in this case that a value of 0 or 1 would be the same. The schedule as shown would execute once per day (FREQ=DAILY), at approximately 15 minutes past a random hour (BYMINUTE=15, but BYHOUR and BYSECOND are not set).
Schedule has nothing to do with whether or not the previous execution succeeded or not. Start Date is only the date at which the job was enabled, not when it actually starts processing.
If you want it to run every 15 minutes from the moment you enable it, you should set as follows:
FREQ=MINUTELY; INTERVAL=15
If you want it to run exactly on the quarter hour, then this:
FREQ=MINUTELY; BYMINUTE=0,15,30,45; BYSECOND=0
If you want it to run every day at 8am, then this:
FREQ=DAILY; BYHOUR=8; BYMINUTE=0; BYSECOND=0

Find the difference between 2 dates and check if smaller than a given value

my issue is that I want to be able to get two time stamps and compare if the second (later taken) one is less than 59 minutes away from the first one.
Following this thread Compare two dates with JavaScript
the date object may do the job.
but first thing i am not happy with is that it takes the time from my system.
is it possible to get the time from some public server or something?
cause there always is a chance that the system clock gets manipulated within the time stamps, so that would be too unreliable.
some outside source would be great.
then i am not too sure how to get the difference between 2 times (using 2 date objects).
many issue that may pop up:
time being something like 3:59 and 6:12
so just comparing minutes would give the wrong idea.
so we consider hours too.
biut there the issue with the modulo 24.
day 3 23:59 and day 4 0:33 wouldnt be viewed proper either.
so including days too.
then the modulo 30 thing, even though that on top changes month for month.
so month and year to be included as well.
so we would need the whole date, everything from current year to second (because second would be nice too, for precision)
and comparing them would require tons of if clauses for year, month, etc.
do the date objects have some predfeined date comparision function that actually keeps all these things in mind (havent even mentioned leap years yet, have I)?
time would be very important cause exactly at the 59 minutes mark (+-max 5 seconds wouldnt matter but getting rmeitely close to 60 is forbidden)
a certain function would have to be used that without fail closes a website.
script opens website at mark 0 min, does some stuff rinse and repeat style and closes page at 59 min mark.
checking the time like every few seconds would be smart.
Any good ideas how to implement such a time comparision that doesnt take too more computer power yet is efficient as in new month starting and stuff doesnt mess it up?
You can compare the two Date times, but when creating a date time there is a parameter of DateTime(value) which you can use.
You can use this API to get the current UTC time which returns a example JSON array like this:
{
"$id":"1",
"currentDateTime":"2019-11-09T21:12Z",
"utcOffset":"00:00:00",
"isDayLightSavingsTime":false,
"dayOfTheWeek":"Saturday",
"timeZoneName":"UTC",
"currentFileTime":132178075626292927,
"ordinalDate":"2019-313",
"serviceResponse":null
}
So you can use either the currentFileTime or the currentDateTime return from that API to construct your date object.
Example:
const date1 = new Date('2019-11-09T21:12Z') // time when I started writing this answer
const date2 = new Date('2019-11-09T21:16Z') // time when I finished writing this answer
const diff = new Date(date2-date1)
console.log(diff.toTimeString()) // time it took me to write this
Please keep in mind that due to network speeds, the time API will be a little bit off (by a few milliseconds)

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.

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