I have a Month View Calendar, and am trying to modify the dataset containing the events.
The default dataset for Month View is (when copy/pasted):
"#NAMES"
"startDate","endDate","displayColor","display"
"#TYPES"
"date","date","str","str"
"#ROWS","4"
"2018-02-21 08:00:35","2018-02-21 12:00:35","blue","Meeting"
"2018-02-21 08:00:35","2018-02-21 09:30:35","red","Email Customer"
"2018-02-21 13:00:35","2018-02-21 15:00:35","orange","Phone Call"
"2018-02-22 08:00:35","2018-02-22 17:00:35","blue","Another Meeting"
Using the example given on this page, I am trying to make a small modification to these events via scripting.
# First create a list that contains the headers, in this case there are 4 headers.
headers = ["startDate", "endDate", "displayColor", "display"]
# Then create an empty list, this will house our data.
data = []
# Then add each row to the list. Note that each row is also a list object.
data.append(["2018-02-21 08:00:35","2018-02-21 12:00:35","blue","First Event"])
data.append(["2018-02-20 08:00:28","2018-02-20 09:30:28","red","Second Event"])
data.append(["2018-02-20 13:00:28","2018-02-20 15:00:28","orange","Third Event"])
data.append(["2018-02-21 08:00:28","2018-02-21 17:00:28","blue","Fourth Event"])
# Finally, both the headers and data lists are used in the function to create a Dataset object
calendar = system.dataset.toDataSet(headers, data)
# Set the month view event property to the new dataset
event.source.parent.getComponent('Month View').events = calendar
However… When I run that sript, everything disappears off my calendar. I am assuming it has to do with the date being passed as a string rather than a date.
How can I format the string as a date?
I’ve tried to use the system.date.parse('2018-02-20 08:00:28','MMMM dd, yyyy hh:mm')
function but
got errors: java.text.ParseException: java.text.ParseException: Unparseable date: "2018-02-20 08:00:28"
Any suggestions?
Eventually I will want these events to be populated from a database, but I was hoping to test my program before integrating the database.