I know this question is a bit generic but bear with me. I have an app which basically posts to website based on a user schedule. Now the app works great locally I m using moment js to compare the scheduled date/time with the current time and then if current time has exceeded scheduled time then that means it should start the auto posting process. The problem arises when I deploy the app to production the time there is different to the time here because of different timezone. How do I ensure (in moment js) that whatever time user schedules at whatever corner of the world the server posts it accordingly and does not start checking on what time it has there. To give you an example at the time of writing this it is Saturday 08/08/2020 00:48 here in PST, the server time is Friday 7/08/2020 19:47. So if I schedule here for say 1am, its only 10 mins to 1am here but for the server there is several hours. how do I manage that? Any ideas or pointing me in the right direction would be really helpful thank you for your time.
You could use moment.utc() on your datetime variable and then you would have 2 options.
Make your system works based on utc timezone always or convert the utc datetime to any timezone you want using the moment timezone library.
https://momentjs.com/timezone/
There could be multiple approaches to solve this problem statement.
One approach is you can calculate the number of seconds from the created time(the current time) to post the content instead of the exact time at the browser from the chosen time by the user and send that to the server to store and run the logic accordingly at the server.
Related
Im using react and node.js
Im trying to build a site that has multiple countdown timers where an user can join in before it hits 0. These countdown timers are displayed based on a pre-set datetime value in the database. When the time hits 0 (datetime is reached) i need that specific timer to become disabled and trigger a function to send out something (like an email) to all those that entered.
I tried looking around but im not sure whats best used for this (must be reliable). I saw cron-scheduler, cron, cron-node etc but maybe im looking at it from the wrong angle... The only requirements are that it needs to trigger at the given datetime and send out a message (like an email, seperately).
Usually timers run for a couple days to maximum a week
We use Django and Celery for our backend serving our APIs. For scheduled tasked we use django-celery-beat. We are running Postgresql for the database and django-celery-beat includes all of the models for the tasks and includes cron.
I am trying to make a bot that sends quotes in servers at different intervals of time (defined by the server admins) by storing the channel id and the time interval (in seconds) inside a db. I managed to get it working for a constant amount of time (say 10 minutes) with #tasks.loop() but I cant figure out how to make it post at different intervals.
Task loops have a method called change_interval which can, as you'd expect, change the interval, you can find out more on here
the scheduler trigger in logic-app is not Triggering as per the schedule
I want to Schedule every-Day b/w 6-10 pm It is Scheduling Manually
please check this below Image for better understanding
Scheduler
please share your Ideas on this
Summarize from the comments, OP mentioned start time was not making an initial effect. According to this information, it is high probability that below is the cause of the problem:
The cause is the format of start time in "Recurrence", if we specify the start time in the format of 2020-09-18T14:00:00Z(with an extra Z), it will apply UTC time zone (so the start time didn't take effect at the beginning and when the UTC time is up to local time, the start time take effect). If we want the start time applies the time zone which we selected, we should specify it in the format like 2020-09-18T14:00:00(without Z).
If I use NodaTime to convert a future date and time to UTC, it uses the Offset of that future date (as known from the global offset database), what happens if suddenly that future offset for a particular Timezone changes because of a Govt change or State referendum changes it (like might happen in QLD and SA in Australia)? Now all my future dates would be out by whatever change they make... It seems unlikely but it is still a valid scenario to think about...
Firstly, you would need to update the data in order to know about the change, and obtain an appropriate IDateTimeZoneProvider in your code. Instructions for that are in the user guide but we hope to make it simpler in the future. In particular:
We already build and publish new data files when IANA publishes a new release of the source data
We expect to create a Nuget package which can also be updated on each new source data release; this would allow users who have regular deployments to pick up the latest one on each build, leaving a relatively small time window where it's out of date
We may provide the building blocks for you to make your app poll and self-update in some form
We're very likely to host the files on a CDN rather than just on the Noda Time web site as it currently is
So that's the matter of getting the new data. How you use it is another matter. If you have stored UTC in your database, you will end up getting a different local time when you later apply the new time zone data to the same timestamps. If that's not what you want to happen - if your app deals with users scheduling events in local time - then you should be storing local time and the time zone, so that a change to the time zone data means a change to the instant in time when the event happens, rather than a change to the local time at which it happens. Of course, you then need to consider what happens if someone scheduled an event at a local time which was going to exist, but later turned out to be a "skipped time" where the clocks are adjusted past it. Noda Time can't make those choices for you, but it does allow you to express your decision reasonably easily with a ZoneLocalMappingResolver delegate, possibly created or obtained via the Resolvers class.
I am building an open sourced nodejs powered sprinkler system which will run on the raspberry pi and work with the OpenSprinkler Pi.
I am using:
sailsjs 0.9.3
laterjs - for schedule interpretation and maths
i created an issue awhile back on bunkats repo asking for him to explain this to me.. https://github.com/bunkat/later/issues/19
The end result will be a REST api interface between rpi and whatever front-end you decide to develop for. web/mobile/cli .. etc.
The way the scheduling component will work is values will be posted to the url /programs with a zone id, name, intial status (false), and a plain text human readable schedule phrase such as: every 12 hours starting on the 6th hour before 10 minutes (06:00 & 18:00 for 10 mins).
This schedule will be parsed, and stringified and stored in db as such:
{\"schedules\":[{\"h\":[6,18],\"m_b\":[10]}],\"exceptions\":[],\"error\":-1}
The other values are cleaned and stored as they were entered.
My question is:
how should I go about finding these schedules and determining their run time/date? I've got the scheduling part, and the run time down and working (run for 10 mins). I'm struggling with the theory behind efficiently retrieving the schedules though.
My initial thought was to have a interval every 1 mins poll the db...
setInterval(function(){
//get programs from db
//iterate through programs
//enable programs which start now?
}, 60000);
But this seems kind of illogical. I suppose that when the schedule is created a setInterval or setTimeout is created with the appropriate scheduling info.. but what happens if the rpi loses power, or those could eat up a bit of memory having all of these intervals hanging out there..
how will it handle existing schedules already in the db?
open source repo
of what i have so far (not much other than the creation api/models/Programs.js) is here:
https://github.com/RelativeMedia/nodesprinkler.git