Design Studio SDK: Simple Date Object Component
Date-based navigation (roll days, months) in BIAL script directly, format days to own formats.
You can use this component like this:
var today = APPLICATION.getInfo().dateNowInternalFormat;
DATEOBJECT_1.rollWeeks(-4); // go back by 4 weeks
var calendarWeek = DATEOBJECT_1.getCalendarWeek();
var dateFormatted = DATEOBJECT_1.format("DD.WW.YYYY"); // -> results in eg. 01.08.2012
Solution for date-based navigation in Filters, eg. get the current date and set the filter on data source by DATE - 4 weeks. Or get the current calendar week from todays day, and get the calendar week which was 2 weeks before. This component contains only some logic in the BIAL script (no rendering).
I have long searched for some option to make this running in BIAL script. The current solution is probably not the best, but this was the only one I can offer for 1.3 release. It is based on "pre-generated JSON values for concrete days.
Secont "problem" was that SDK is always sending all properties to the client, therefore I hold only the "oneDay" property as this is small, I need to clean up always the "days" property as this is holding a huge array of days. Seems to work correctly - the array will never be send to client.
Currently no properties.
You can initialize the simple date object with any date from January 2009 to December 2019 by giving year, month, day
You can initialize by passing the internal date format "20140814" (8 characters). This is for direct passing of the "APPLICATION.getInfo().dateNowInternalFormat;" content.
functions for rolling the date object. You can use NEGATIVE numbers to roll down.
many getters (in this preview no documentation, but the names are self-explained)
format method can be used for formatting of the date to some string (primitive format by replacing characters):
|internal_*||some internal methods, do not use directly|
An Application with example can be downloaded at the BIAPP Repository:
- DesignStudioBiAppRepository/SDK_SIMPLEDATE at master · KarolKalisz/DesignStudioBiAppRepository · GitHub
In this example all methods are shown behind the buttons, try it out!
- currently, in BIAL scripts only restricted functional scope is possible, therefore the dates are as "big array" (but performance seems to be ok)
- restricted to navigation between 31st December 2004 and 1st January 2020 - this shoudl be ok for normal use
Source Code & Licensing
This component is for free use. It is under the Open Source Apache Version 2.0 License.
Important Maintenance Notice (... as I am SAP Employee)
The component is NOT delivered under SAP maintenance license.
You cannot claim any Support on this component from SAP!
The components are created on "private" basis - you can use them as is. I can modify (in compatible way), correct or improve - but there is no obligation to do it. Of course I will try to correct bugs or improve the component as long I can.
Feel free to add any comments or ideas which can go into future versions, or feel free to take a copy and add extensions on your own.