Rundeck time format - rundeck

In the "Activity for jobs' page in Rundeck the execution time has a relative time field (example: "Today at 10:15 AM" or "Last Sunday at 4:51 AM") after the timestamp.
It is easy to change the date format of the timestamp by adding jobslist...format[.ko] in the i18n/messages.properties file.
It seems impossible however to change the format of the relative time message. It seems to be hard-coded in en_US with AM/PM which doesn't look too good in in non-English-speaking countries. The format is always the same regardless of the ?lang=xx parameter or the default language in the browser. Interestingly, other objects (like hovering over the field with the mouse and the duration get translated).
Has anyone successfully changed this?
Example. See the duration field
I have been trying this with the docker images (4.8.0, 4.9.0 and SNAPSHOT)
I've looked at the source code and apparently this lies somewhere in the moment.js code.

In some parts, the date formats are hard coded as you say, please add your use case on this thread.

Related

Powershell simplest method to get current time expressed as UTC

I have reviewed the post Creating a DateTime object with a specific UTC DateTime in PowerShell, but it does not seem to directly answer the question I am asking:
What is the most direct method in PowerShell (3.0) to return a sortable string representing "now" as UTC?
I expected the correct answer to be:
Get-Date -Format (Get-Culture).DateTimeFormat.UniversalSortableDateTimePattern
OR
get-date -format u
but this is not the case.
Example: At 1300 hrs (1pm) on September 1st, 2016 in the Pacific Time Zone during DST, I get the response:
2016-09-01 13:00:00Z (the local time with a "Z" appended)
when I was expecting:
2016-09-01 20:00:00Z (correct UTC/GMT time)
So basically, my code is just getting a string representing the "local" time and appending a "Z".
Now, I know I can manipulate to get to that point, but I'm looking for the minimal (simplest, cleanest) way to get here.
Bonus Points (as if they existed): How do I get that same, sortable result, but displaying with "UTC" and/or "GMT" as the suffix. Same minimal requirement.
Probably something like this:
[DateTime]::UtcNow.ToString('u')
Which is equivalent to:
[DateTime]::UtcNow.ToString((Get-Culture).DateTimeFormat.UniversalSortableDateTimePattern)
For the bonus, I think the most straightforward way is just to replace Z with UTC:
[DateTime]::UtcNow.ToString('u').Replace('Z','UTC')
I'm assuming you'll always want UTC since that what it seems like from your question. There doesn't appear to be a format string to get just the 3 letter time zone.
I tried this, and it also gives the result I want:
"[DateTime]::UtcNow.ToString('yyyyMMdd_HHmmss_UTC')"
It is showing time in the format 20180108_152407_UTC
so you can play with the date/time formatting as you wish basically

Displaying the timezone properly in XSLT

Was using the below tag for displaying the timezone which was working fine until now when the daylight saving has happened and as our server is in UK displaying the time as 01/04/2015 03:43:00 PM + 0100, we would also like to have the timezone displayed, please advice.
Tag Used Previously:
date:format-date(date:date-time(), 'dd/MM/yyyy hh:mm:ss a Z')
Regards
Arvind
If by "properly" you mean you want it displayed as "BST" (for British Summer Time) then there isn't actually enough information in the date/time value to do this - a time-zone offset of +1 occurs in many different timezones near the Greenwich meridian.
You're using the EXSLT library for formatting dates and times. This is based on Java's SimpleDateFormat class, so you could try your luck with the timezone designator z instead of Z.
Alternatively, if you've got access to XSLT 2.0, you can use the format-dateTime() function. This suffers from the same problem (the dateTime value only stores an offset, which doesn't actually tell you the name of the timezone). But you can give the processor a clue by setting the 5th argument of format-dateTime() to "Europe/London", in which case it might be able to work it out.

Format causes a subtraction of exactly 4 hours from the hour field every time

For all of my dates, Format subtracts exactly 4 hours from the hour field.
Here is an example for clarification:
When I retrieve a date in Microsoft SQL Server Management Studio, the date column returns dates in this format: 2014-10-30 11:19:02.733.
When I execute the same command using sql and display the value in a gridpanel, it is displayed in this format: 2014-10-30T11:19:02.733.
However, When I try to use Format="yyyy-M-d, HH:mm", the date is returned as 2014-10-30 07:19:02.
For easier comparison, this is what the difference is:
2014-10-30 11:19:02.733
2014-10-30T11:19:02.733
2014-10-30 07:19:02
What could cause the removal of exactly 4 hours every single time?
Thank you.
Additional code:
<ext:DateColumn ID="Column6" runat="server" Text="When" DataIndex="time" Flex="1" Format="yyyy-M-d, HH:mm" />
For anyone who stumbles upon this question in the future:
I found the solution, based on Julien's guess!
I changed the timezone on my pc and it consequentially changed the value again.
It turns out, that the way around this is is to add a type to the modelField. It would look something like this <ext:ModelField Name="time" Type="Date" />.
For some reason, this prevents the client-side time-zone override.

Importing ICS into Google Calendar with correct timezone

I'm trying to import a simple ics file into Google calendar. However, even though I have the timezone specified, Google calendar still imports the wrong event time. (Although it does say that the wrong time is in the correct timezone.)
Here is a sample of my ics file:
BEGIN:VCALENDAR
BEGIN:VEVENT
DESCRIPTION: Test_Description
DTEND;TZID=US-Pacific:20140606T180000
DTSTART;TZID=US-Pacific:20140606T170000
LOCATION:Test_Location
SUMMARY:Test_Summary
UID:20140606T150000#NL
END:VEVENT
END:VCALENDAR
This event should show up as occurring on June 6, from 5PM-6PM Pacific Standard Time. However, on my calendar it shows up as occurring on June 6, from 10AM-11AM PST.
I think (although have not implemented) a hack to just change everything to UTC and adjust the event time accordingly might work. However, this would be a little annoying to implement and honestly Google Calendar should be able to handle this simple of an import.
Does anyone have any suggestions to deal with this, or see any bugs in my ICS file?
Thanks!
To make your ICS work with Google's "Add by URL..." specify your timestamps in UTC and add the X-WR-TIMEZONE. Timestamp must have the Z at the end to mark the timestamp as UTC:
DTSTART:20140102T110000Z
Also add the timezone specification in the VCALENDAR block like this:
X-WR-TIMEZONE:Europe/Zurich
After adding the calendar in Google Calendar, the time zone for should be set correctly in the calendar's settings.
If you are using PHP to generate the ICS, you can convert the timestamps to UTC like this:
// The timestamp in your local time and your local time zone
$timestamp = "01.01.2016 12:00";
$timezone = new DateTimeZone('Europe/Zurich');
// The UTC timezone
$utc = new DateTimeZone('UTC');
// Create a DateTime object from your timestamp using your local timezone
$datetime = DateTime::createFromFormat("d.m.Y H:i",$timestamp, $timezone);
// Set the timezone on the object to UTC.
$datetime->setTimezone($utc);
// Print the time in UTC and use the correct format for ICS
echo $datetime->format('Ymd\THis\Z');
This also works on Apple's iPhones.
Normally it is required to include VTIMEZONE objects. Many people are starting to omit that, but if you do, at least use an olson-identifier. This should be enough for google calendar to pick up the correct timezone.
An example of an olson identifier is Europe/Amsterdam. Look up the identifier the most appropriate for you. Presumably this is something like America/Los_Angeles.

Facebook-like "time since" calculation algorithm

On Facebook, each comment or other user event has a timestamp. But it is not listed as a simple date, but presented in a form of a human-friendly string. For example if right now it is 08:38 and the comment was made at 08:31, Facebook doesn't just tell you the time, but says "7 minutes ago".
Is there an open source implementation of Facebook algorithm (or similar) that takes a data of event, a current date and tells in a human-friendly form how long has it been since?
Pretty date http://ejohn.org/projects/javascript-pretty-date/ is a good javascript library for this
You could dig into timeago jQuery plugin's source code to study.
What I think that should be the best is this :
Store the timestamp when the comment is made (eg- 3:45 12-10-2012)
Get the current system time
Get the differnce between the two .i.e (current time -comment time ) .
Most of the languages provide the datediff method . Like in PHP you can use it like this