I have an ActiveSuppport::TimeWithZone object and I want to find out how many minutes after 11 AM on that day it is. So, for example, if the time is 11:47 AM, I want the answer to be 47.
Is there a way in Ruby/Rails to do this.
Thanks!
Subtracting one Time object from another gives the difference in seconds. Just divide by 60 to get minutes.
(mytime - Time.parse('11 AM')) / 60
Related
I have a spreadsheet that receives data from an RPA, this data is HH:MM, the output is based on how long a task has taken to perform.
example:
Project
Time
Task 1
2:35
Task 2
3:45
Where 2:35 is equal to 2 hours and 35 minutes.
The issue that i am having is that when I add these numbers google sheets displays it as 5:80, where it should be 6:20, as that is the actual amount of hours and minutes represented in the table. In other words I would like the decimal counter to stop at 60 and add new, not at a 100?
Anybody have an idea of how to achieve this? :)
-- Toby
In order for the duration formatting to work the delimeter must be the correct standard according to the language you are working in.
This is most likely something I am missing but I have the following code:
console.log(results[0].get('updatedAt'));
data.currentBalanceLastUpdated = moment.utc(results[0].get('updatedAt')).fromNow();
The console log outputs: 2019-03-31T21:09:11.612Z which from my understanding should be UTC declared for moment to convert from. However, when I do this, my data.currentBalanceLastUpdated comes out to be "5 hours ago) and it shouldn't be as I just updated it a few minutes ago.
Am I missing something here?
Whether the input time is in UTC or local time, it doesn't really matter. If it happened 5 minutes ago, it happened 5 minutes ago regardless of timezone, and moment should get this right.
If you are getting a result that's different from what you expect, I would say it's more likely that you're storing it incorrectly.
I tried to schedule a job run every 28 days but still not have solution yet.
Please help!
Thank!
As the documentation shows, using */X executes in intervals of X.
So, applying this to the "day of month" field, under "Build periodically", you could use the following to build at some consistent point in time once every 28 days:
H H */28 * 2
As an example, the 2 at the end signifies that the build should run on a Tuesday. Otherwise, it will probably build on whatever day of the week the current month started with.
I didn't try it yet so I may be wrong, but how about putting days as hours.
For example, if you want to run Jenkins job every 10 days, you schedule it to run every 240 hours.
In my project, I need to store the clusters as snapshots by means of pyramidal time frame . I have already referred many sites but i couldn't understand how it works. Please can anyone explain this with an example ?
Hierarchical aggregation of different time frames.
Say your lowest granularity is 1 minute, then 15 minutes, 60 minutes, 6 hours, 1 day, 1 week...
You can draw them like a pyramid. 1 week is 7 days is 28 6hour frames, is 24*7hours, ...
I want to have a countdown from the current time to a specific schedule like this:
8:48, 9:29, 11:56, 12:36, 13:18, and ect. and display that value in a label.
For example. Now we have 11:00 o'clock. And UILabel tell us 56 minutes remaining. And after 11:56 it tell us 40 minutes remaining (from current 11:56 to 12:36).
I don't ask you code directly, just help to find right way to search.
Thanks.
some links by searching google
Implementing a Countdown Timer in Objective-c?
http://looksok.wordpress.com/2012/12/29/ios-timer-countdown-implementation-tutorial-including-source-code/
and implementation
https://github.com/jonhernandez/iOS-Timer-Countdown
I havent looked at code quality, but it should get you started