Add seconds to an existing date in Lua - lua

I want to calculate time in Lua.
For example: I want to get the current date (incl. at least seconds) and then I want to add seconds to this date that I get a date which is in the future.

Try this:
now=os.time()
print(os.date("%c",now))
print(os.date("%c",now+10000))

Related

Update: How to calculate date and time duration into Days in google shee? (excluding Sunday)

I know it's basic but I'm new to this. I just want to know how can I calculate the days duration of the two dates?
For example, I have my start date and time 11/22/2021 15:20:43 and end date and time 11/23/2021 14:51:29 I want to calculate the total days from start to end date and time.
Also, If start date time column is BLANK, return to count of days including date today.
Thank you
All you need to do is use the following formula: '=(C2-A2)'. This will give you the elapsed time between the two cells and display it as hours. You can take this calculation further by adding dates too. This is useful if you have work shifts that go more than 24 hours or that include two days within a single shift.
Assuming start dates in column A and end dates in column B, you can try
={"Duration in Days"; Arrayformula(if(len(A2:A) * len(B2:B), datedif(A2:A, B2:B, "d"),))}
Change ranges to suit and see if that works?
EXAMPLE
REFERENCES:
DATEDIF
there is a DAYS formula exactly for that purpose:
update:
=INDEX(IFERROR(1/(1/DAYS(
REGEXREPLACE(TO_TEXT(B1:B), "(.|..)[\/\-\.](.|..)[\/\-\.](.+) (.*$)", "$2\/$1\/$3"),
REGEXREPLACE(TO_TEXT(A1:A), "(.|..)[\/\-\.](.|..)[\/\-\.](.+) (.*$)", "$2\/$1\/$3")))))
demo sheet

How to convert Server Date format in hour or day?

How I will change this date format to in a day or hours
"modifiedTime": "2021-01-30T12:15:14.896Z[GMT]",
"modifiedTime": "2021-01-29T13:58:37.328Z[Etc/UCT]",
DateTime.parse(aString) should handle a Z suffix for timezone or an explicit offset (-05:00). To parse other named timezones, you'll need the https://pub.dev/packages/timezone package, which unfortunately has to get updated at least a few times a year because politicians keep messing with things like DST.

When making an API call to omniture (site catalyst) , is there any way to use rolling dates

i have created a dashboard in klipfolio and only need 52 weeks data to be fetched by the api with respect to current date .. currenlty i m manualy passing date but i want it to use the system date to automaticall fetch data for me
"dateFrom": "2018-01-10",
"dateTo": "2018-02-05",
You can use Klipfolio's date parameters to accomplish this. In your example, you want the last 52 weeks from today so your query for dates could look like this:
"dateFrom": "{date.addWeeks(-52).format()}", "dateTo": "{date.today}",
Alternatively, if you want it to start on first day of the week 52 weeks ago, your query for dates could look like this:
"dateFrom": "{date.addWeeks(-52).startOfWeek.format()}", "dateTo": "{date.today}",
This will create a 52 week rolling window relative to today so you will not have to update your query every week.

Format times to display with 'AM/PM'

Normally, when I enter times in Google spreadsheet as 22:00:00 the display automatically switches to 10:00 PMbut sometimes it's not converting.
How can I set a common format for times in Google spreadsheet? I need this format: 8:00 PM.
Select all ranges that you wish to have this time format and go to Format > Number > More formats to select the one of your choice. (I think the one you want is near the bottom and shows as 3:59 PM.)
If you want to format a time with TEXT() to display with am/pm you can use:
=TEXT(DateField, "HAM/PM")
To get a results like
1am
1pm
10pm
12am
Use UPPER() to make it uppercase.

evaluate difference between 2 dates to make a transition possible

Is this possible to evaluate the duration between a specified date on a form of a workflow, and the system date ? that what I want to do, in order to show (if this possible too) a short message if 1 day occurs since the specified date above, forbidding the transition of the status Closed to Reopened...
Thanks a lot,
Christophe
I think the Script Runner has a validator that does something like this but I can't find it. Then you could write a post function with the Script Runner. Otherwise it's back to creating a custom validator, as described in my book Practical JIRA Plugins (O'Reilly)
You can use the ScriptRunner plugin in addition with the following script in the validator section for the Reopened transition:
Date now = new Date()
Date cfDate = new Date(cfValues['YourCustomField'].getTime())
new Date(now.getYear(), now.getMonth(), now.getDate()).compareTo(cfDate) <= 0
Replace YourCustomField with the name of your custom field. This will ensure that the transition will check whether the current date is beyond the date set in the custom field, and blocks it if it is.
First of all, thank you for your answer.
It works to allow transition when dates are similar, but my purpose was modified by my responsible. He would like to allow the transition if dates are similar or if the duration between them is only 1 day or less.
Example :
System date is 09/07/2013 (Paris)
My date (dd/mm/yyyy format) Transition allowed Why
07/07/2013 NO my date is former to system date
08/07/2013 NO my date is former to system date
09/07/2013 YES my date and system date equals
10/07/2013 YES only 1 day occur between 2 dates
11/07/2013 NO 2 days occur between 2 dates
Here is the code I wrote in order to do that, but it does'nt work (maybe a Java syntax error?) :
Date now = new Date()
Date cfDate = new Date(cfValues['Date de clôture réelle de la demande'].getTime())
new Boolean(((now.getTime() - cfDate) / 86400000) <= 1) && (now.getTime() >= cfDate ))
Excuse me for my english. I'm french, and I try to improve my English.
Thanks a lot.

Resources