Appointment Type in iCalendar - icalendar

In normal LotusScript you can use the item "AppointmentType" to set: Appointment=0, Anniversary=1, Event=2, Invitation=3, Reminder=4.
I would like to use iCalendar, but I haven't found a way to include the type of an appointment in the format. I experimented with X-LOTUS-APPTTYPE, but without an effect (Appointment stays 4).
Thanks in advance!

If you want the type to be recognised by all calendar apps, then consider use a standard RFC 5545 field - maybe the CATEGORY field https://www.rfc-editor.org/rfc/rfc5545#section-3.8.1.2

Related

GEE Feature Collections and Dates

I have a fusiontable based feature collection in Google-Earth-Engine that includes a date column. I would like to cast the FC into an empty image and display with graduated colours for increasing dates - so that when the Inspector is used a human readable date is displayed.
var empty64 = ee.Image().toInt64();
var outlines = empty64.paint({
featureCollection: SomeFeatureCollection,
color: 'StartDate',
});
If I add this to the map as a layer I get the date as a 13-digit format that I can't read. How can I change this?
Thank you!
Per the API reference for Image.paint, color must be an object name or a number. To me, that means the EE API will interpret the object as a number, meaning a Date object will be converted from a string to a numerical representation. In this case, that's the "milliseconds since epoch" format.
Without a way to add metadata to a FeatureCollection (i.e. so you could store the associated datestring along with the other parameters of the feature), I don't think you can show a human readable date in the inspector.

How to handle date input in Laravel

I'm working on an app that allows the user to edit several dates in a form. The dates are rendered in the European format (DD-MM-YYYY) while the databases uses the default YYYY-MM-DD format.
There are several ways to encode/decode this data back and forth from the database to the user, but they all require a lot of code:
Use a helper function to convert the date before saving and after retrieving (very cumbersome, requires much code)
Create a separate attribute for each date attribute, and use the setNameAttribute and getNameAttribute methods to decode/encode (also cumbersome and ugly, requires extra translations/rules for each attribute)
Use JavaScript to convert the dates when loading and submitting the form (not very reliable)
So what's the most efficient way to store, retrieve and validate dates and times from the user?
At some point, you have to convert the date from the view format to the database format. As you mentioned, there are a number of places to do this, basically choosing between the back-end or the front-end.
I do the conversion at the client side (front-end) using javascript (you can use http://momentjs.com to help with this). The reason is that you may need different formats depending on the locale the client is using (set in the browser or in his profile preferences for example). Doing the format conversion in the front-end allows you to convert to these different date formats easily.
Another advantage is that you can then use the protected $dates property in your model to have Laravel handle (get and set) these dates automatically as a Carbon object, without the need for you to do this (see https://github.com/laravel/framework/blob/master/src/Illuminate/Database/Eloquent/Model.php#L126).
As for validation, you need can then use Laravel's built-in validation rules for dates, like this:
'date' => 'required|date|date_format:Y-n-j'
While client-side is good for UX, it doesn't let you be sure, all will be good.
At some point you will need server-side validation/convertion anyway.
But here's the thing, it's as easy as this:
// after making sure it's valid date in your format
// $dateInput = '21-02-2014'
$dateLocale = DateTime::createFromFormat('d-m-Y', $dateInput);
// or providing users timezone
$dateLocale =
DateTime::createFromFormat('d-m-Y', $dateInput, new DateTime('Europe/London'));
$dateToSave = $dateLocale
// ->setTimeZone(new TimeZone('UTC')) if necessary
->format('Y-m-d');
et voila!
Obviously, you can use brilliant Carbon to make it even easier:
$dateToSave = Carbon::createFromFormat('d-m-Y', $dateInput, 'Europe/London')
->tz('UTC')
->toDateString(); // '2014-02-21'
Validation
You say that Carbon throws exception if provided with wrong input. Of course, but here's what you need to validate the date:
'regex:/\d{1,2}-\d{1,2}-\d{4}/|date_format:d-m-Y'
// accepts 1-2-2014, 01-02-2014
// doesn't accept 01-02-14
This regex part is necessary, if you wish to make sure year part is 4digit, since PHP would consider date 01-02-14 valid, despite using Y format character (making year = 0014).
The best way I found is overriding the fromDateTime from Eloquent.
class ExtendedEloquent extends Eloquent {
public function fromDateTime($value)
{
// If the value is in simple day, month, year format, we will format it using that setup.
// To keep using Eloquent's original fromDateTime method, we'll convert the date to timestamp,
// because Eloquent already handle timestamp.
if (preg_match('/^(\d{2})\/(\d{2})\/(\d{4})$/', $value)) {
$value = Carbon\Carbon::createFromFormat('d/m/Y', $value)
->startOfDay()
->getTimestamp();
}
return parent::fromDateTime($value);
}
}
I'm new in PHP, so I don't know if it's the best approach.
Hope it helps.
Edit:
Of course, remember to set all your dates properties in dates inside your model. eg:
protected $dates = array('IssueDate', 'SomeDate');

Customizing phone number or any other String for different Locales in GWT

I am trying to find the best route to get in some Custom formats I need. For example if I have a phone number 0803456765
In India it may be represented as +91 (080) 3456765
In US it may be 080-345-6765 and so on
I could keep the format in the properties file and based on locale I could pull the format and format the String. I could also have a Util class which does this for me after I identify the Locale.
But I think there might be a better route using NumberFormat. I guess NumberFormat automatically figures out the Locale and applies a certain Pattern to the String. Can I customize this pattern ? In the sense, can I tell GWT to use my Custom pattern for the US Locale
I know we can do this
// Custom format
value = 12345.6789;
formatted = NumberFormat.getFormat("000000.000000").format(value);
// prints 012345.678900 in the default locale
GWT.log("Formatted string is" + formatted, null);
but I don't want to specify my formatting pattern as in 'NumberFormat.getFormat("000000.000000")'. I want to override the default number formats of various Locales in GWT to achieve this. How do I do this ?
Don't roll your own. Google open sourced their library which you can leverage. It supports
Parsing/formatting/validating phone numbers for all countries/regions
of the world.

exclude time periods in iCalendar

i have a very simple vevent "every Monday 9 to 5" and some time periods where this event doesn't take place. like 7.8.2011 to 24.10.2011. What is the best way to represent this in iCalendar?
a lot of EXDATEs? special EXRULEs?
Oh dear,
Exrule is deprecated now in RFC 5545, so best skip that one (although that would be neatest and most ics s/w probably still copes with it (like mine :), for compatibility )
EXDATES are valid, but gosh that would be cumbersome if you mean the whole period from 7 August to 24 October, you'd have to enter every week day
You possibly have to just create two events - although one could 'relate' them.
I have not tried it yet, have been thinking about if for a different reason, but there is the concept of 'RELATED-TO' with modifer RELTYPE (PARENT, SIBLING etc)
RELATED-TO;RELTYPE=SIBLING:19960401-080045-4000F192713#
example.com
Property Name: RELATED-TO
Purpose: This property is used to represent a relationship or
reference between one calendar component and another.
Value Type: TEXT
Property Parameters: IANA, non-standard, and relationship type
property parameters can be specified on this property.
Conformance: This property can be specified in the "VEVENT",
"VTODO", and "VJOURNAL" calendar components.
Description: The property value consists of the persistent, globally
unique identifier of another calendar component. This value would
be represented in a calendar component by the "UID" property.

Change article_custom so that 'past' doesn't exclude an event on the current date

I'm using textpattern and trying to display a list of upcoming events. I'm using article_custom.
<txp:article_custom
form="eventshome"
limit="4"
time="future"
sort="Posted
section="events" />
The issue I have is that this is supposed to show events coming up but using 'future' means that when an event is on the current date it's not showing (it's not future anymore). Both 'past' and 'future' time options seem to exclude the current date. That means people coming on the site don't see an event on that day which is a bit of an issue.
I've had a quick look around the code but can't seem to work out how to change the SQL statement so that future includes the current date.
Any help appreciated.
Its a bit oldie, but since i've just fixed the same issue, i thought i could provide my very simple soution to this matter.
What i did was simply set article date and time to its date and 25:59:59 time, so its visible all day on current day, but disappears immeadetly when day changes.
Since i didn't want to type those times always again and again, i run small javascript on article page which sets those automaticly to fields.
You can try plugin smd_calendar - http://stefdawson.com/sw/plugins/smd_calendar
it supports a lot of methods to display upcomming and past events.