Caldav not returning event within time-range query - icalendar

I have an iCalendar event in my Sabre:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//CalDAV Client//EN
BEGIN:VEVENT
UID:5e44cec8-33ed-4f24-82c7-f33483afa50d
DTSTART:20200805T080000Z
SUMMARY:summary
STATUS:CONFIRMED
TRANSP:OPAQUE
DURATION:PT30M
CATEGORIES:RESERVATION
DTSTAMP:20200716T211928Z
END:VEVENT
END:VCALENDAR
It starts at '2020-08-05T08:00:00.000Z' and with duration of 30 minutes, ends at '2020-08-05T08:30:00.000Z'.
If I submit the following query:
<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav"
xmlns:cs="http://calendarserver.org/ns/"
xmlns:ca="http://apple.com/ns/ical/"
xmlns:d="DAV:">
<d:prop>
<c:calendar-data />
</d:prop>
<c:filter>
<c:comp-filter name="VCALENDAR">
<c:comp-filter name="VEVENT">
<c:time-range start="20200805T080000Z" end="20200805T180000Z"/>
</c:comp-filter>
</c:comp-filter>
</c:filter>
<c:timezone>GMT</c:timezone>
</c:calendar-query>
The mentioned event gets returned. However if I move the start=... even just by one second, like so start="20200805T080001Z" it does not get returned.
According to section 9.9 or Caldav RFC 4791, it should be returned. Condition from the mentioned section:
(start < DTSTART+DURATION AND end > DTSTART)

I figured it out, I'm using Mongo Backend instead of Sabre's PDO Backend and the mentioned Mongo Backend has an error that the PDO one doesn't.
Piece of code causing the error:
$endDate = clone $component->DTSTART->getDateTime();
$endDate->add(VObject\DateTimeParser::parse($component->DURATION->getValue()));
$lastOccurence = $endDate->getTimeStamp();
endDate is an Immutable Date and therefore endDate needs to be reassigned for the add function to take any effect.
Fixed code:
$endDate = clone $component->DTSTART->getDateTime();
$endDate = $endDate->add(VObject\DateTimeParser::parse($component->DURATION->getValue()));
$lastOccurence = $endDate->getTimeStamp();
You can also see this correctly implemented on the github page of the PDO Backend here.

Related

Rundeck time format

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.

How can you set a timezone in an outlook.com link?

I'm trying to set correct times for an Outlook event in the UK, but Outlook seems to set the incorrect time for BST (British Summer Time).
Here is a link, which creates an event for 19th June 2017 at 1254pm to 1257pm.
In my Outlook it opens an hour ahead as 1354pm. Is there a way to explicitly set the timezone in the link?
I've tried checking my settings and using a different Outlook account so I don't think it's an issue with my mail/calendar settings.
https://bay02.calendar.live.com/calendar/calendar.aspx?rru=addevent&dtstart=20170619T125400&dtend=20170619T125700&summary=Summary+of+the+event&location=Location+of+the+event&description=example+text.&allday=false&uid=
After researching quite I've realised that Outlook always expresses time in UTC when sending a link. Therefore you need to convert the date/time from BST to UTC. You can do this with PHP like this:
$date = new DateTime('2017-06-22T12:54', new
DateTimeZone('Europe/London')); /* <-- Time zone to be converted */
echo $date->format('YmdHis') . "\n";$date->setTimezone(new
DateTimeZone('UTC'));echo $date->format('YmdHis') . "\n"; /* <-- New time zone, UTC */

SOAP UI variables (e.g., date)

I am using SOAP UI Pro. I have a request from which this is an excerpt:
<ns2:OfficeType>
<ns2:OfficeTypeCode>M</ns2:OfficeTypeCode>
<ns2:EffectiveDate>2000-01-01</ns2:EffectiveDate>
<ns2:TerminationDate>9999-12-31</ns2:TerminationDate>
<ns2:IsPrimary>true</ns2:IsPrimary>
</ns2:OfficeType>
Instead of for instance, 2000-01-01, I want to use today (so for the day I am writing this it would be 2015-03-10. You may be reading on March 12 in which case it would be 2015-03-12, etc.). I could theoretically edit the SOAP request each time I send it out and replace the fields with the current date, but this is supposed to be automatic. I would like a say to say, instead of 2010-01-01 use something like $(Today'YYYY-MM-DD') (that is just an example probably nothing near the actual syntax).
Is there a way to get the current date placed into a SOAP UI message from SOAP UI Pro?
In SOAPUI you can use groovy code directly in your SOAP Request using the follow notation ${=groovy expression}, so in your case you can use ${=new java.text.SimpleDateFormat("yyyy-MM-dd").format(new java.util.Date())} to get today date in yyyy-MM-dd format.
Directly in your test request you can use:
<ns2:OfficeType>
<ns2:OfficeTypeCode>M</ns2:OfficeTypeCode>
<ns2:EffectiveDate>${=new java.text.SimpleDateFormat("yyyy-MM-dd").format(new java.util.Date())}</ns2:EffectiveDate>
<ns2:TerminationDate>9999-12-31</ns2:TerminationDate>
<ns2:IsPrimary>true</ns2:IsPrimary>
</ns2:OfficeType>
Hope this helps,
This will give you a nice UTC formated date/time:
<ns2:EffectiveDate>${=java.time.Instant.now().truncatedTo(java.time.temporal.ChronoUnit.SECONDS)}</ns2:EffectiveDate>
If you are using SoapUI Pro, then you may have the following script in TestRunListener.beforeRun Event
import java.text.SimpleDateFormat
def today = new Date()
def dateFormat = new SimpleDateFormat("yyyy-MM-dd")
def date = dateFormat.format(today)
log.info date
testRunner.testCase.setPropertyValue('DATE', date)
And in the request have
<ns2:EffectiveDate>${#TestCase#DATE}</ns2:EffectiveDate>
i.e., using the value DATE which was set in the beforeRun event.
Note: You can change the date format whatever you want, here it is used yyyy-MM-dd format as you mentioned in the question.

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.

Get users current date

I need to check what’s the current date where the user is in.
I don’t need the time, just the current date.
How can i do it?
I'm using codeigniter.
Thanks.
I've managed to get the date on the client side.
My problem is that i get an error (0) when trying to parse it using strtotime.
I know that means the string is not ok but when i do an echo it displays ok(07/11/2010).
Here's the code:
javascript:
function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year
HTML:
$curdate="";
$newdate = strtotime ( '-0 year' , strtotime ( $curdate ) ) ;
$curdate=date ( 'Y-m-d' , $newdate );
echo form_hidden('curdate','',$curdate);
The web server and, by extension, your application do not have this information. You have to get that input from the client side somehow. A couple of ideas come to mind:
Ask the user what time zone they're in (e.g., with a form), then calculate their date based on that.
Use some JavaScript that finds the information automatically (e.g., getTimezoneOffset()). Optionally, submit this information to your app via Ajax.