I'm developing an iOS app that accesses a Google Calendar to display dates of upcoming livestreams.
Google claims that for any argument that takes a DateTime, it must be formatted as ISO 8601, which I understand should look like this: 2015-05-17T18:49:11-07:00 (I live in Southern California, which is normally UTC-08:00 but right now is UTC-07:00 because of Daylight Savings Time) Anyway, in my own testing, my app is generating URLs like the following:
https://www.googleapis.com/calendar/v3/calendars/CALENDAR_IDENTIFIER/events?orderBy=startTime&q=Live&singleEvents=true&timeMin=2015-05-17T18:49:11-07:00&timeMax=2015-06-16T18:49:11-07:00&key=API_KEY
and these are working perfectly, they return the expected calendar data.
However I just recently added a tester who lives in New Zealand, who is in UTC+12:00. His app is generating URLs such as this:
https://www.googleapis.com/calendar/v3/calendars/CALENDAR_IDENTIFIER/events?orderBy=startTime&q=Live&singleEvents=true&timeMin=2015-05-17T13:49:11+12:00&timeMax=2015-06-16T13:49:11+12:00&key=API_KEY
however for him they are NOT working, they return a "400 Bad Request" error from Google.
I did some experimentation, and in my findings, any negative UTC offsets that I try work correctly (e.g. Hawaii, who is UTC-11:00, Anchorage which is UTC-09:00) however none of the positive GMT offsets work (New Zealand # UTC+12:00, Japan # UTC+09:00)
What am I doing wrong?
Edit: I've worked around the issue for now by converting all of my times into UTC and specifying them as, e.g., 2015-05-17T18:49:11Z, then adding timeZone=America/Los_Angeles (or Asia/Tokyo or wherever the user is) to the API call. Google seems to accept this. I'd still like to know why, even though they claim that ISO 8601 format strings are accepted, they in actuality aren't (this is especially odd/puzzling/frustrating considering that Google's reply, i.e. the actual calendar data that my app receives, in fact, actually contains ISO 8601 date strings with positive offsets, such as 2015-06-15T09:00:00+09:00.)
Yep, this seems to be a bug. I'm in Spain (UTC+01:00) and I was going crazy with this, given that the response data is as you say formatted with the positive offset.
I'm using it for the timeMin paramter in the http request to get only future events. Ended up putting the current datetime adding the last "Z" as string. Apparently works fine, but I'm in the same timezone the calendar has defined. When that is not the case I guess you have a problem there if you want it with hour precession.
The timeZone parameter apparently is only for the response data.
It works if + is encoded as %2B.
Related
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.
Im using the CalendarApi in flutter and in order to get events I use the list method like that:
calendarApi.events.list(
cls.calendarId,
timeZone: <specific timezone>
timeMin: DateTime.now().today().toUtc(),
timeMax: DateTime.now().tomorrow().toUtc(),
),
No matter what timezone I tried it always return the event start and end date in UTC format.
I tried using the timezones in multiple formats:
America/Los_Angeles
UTC - 08:00
GMT format
Pacific Standard Time
None of the following worked.
In addition in the in google calendar's settings the timezone is set correctly.
From the documentation:
Must be an RFC3339 timestamp with mandatory time zone offset, for example, 2011-06-03T10:00:00-07:00, 2011-06-03T10:00:00Z. Milliseconds may be provided but are ignored. If timeMax is set, timeMin must be smaller than timeMax.
Make sure the strings you are sending follow one of these pattens:
YYYY-MM-DDTHH:MM:SS±HH:MM
or
YYYY-MM-DDTHH:MM:SSZ
So for example, the time that this answer was posted would be:
2021-07-27T16:08:02+02:00
or:
2021-07-27T14:08:02Z
Where the Z signifies 'Zulu', or 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
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.
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.