In previous post I've told how to use Persian Datepicker so this post shows how to add some options to this Datepicker.
Unfortunately after we added *.js file in terms of Persian Datepicker, if we want to set values for some properties will not work and we could not use them. But it can be add jQuery codes and active these properties.
We add codes in Execute When Page Load for each page or if we would like for an application and all pages, can be to add to template.
Shows Years and Month
//be change year and month $( ".apex-item-datepicker" ).datepicker( "option", "showOtherMonths", true ); $( ".apex-item-datepicker" ).datepicker( "option", "changeMonth",true ); $( ".apex-item-datepicker" ).datepicker( "option", "changeYear", true );
Tip: if we change some options manually that cause to lost some classes on datepicker' button and for solving this issue we must add a line code at latest line.
//be lost Button clasess so to fix the issue with the button trigger $(".ui-datepicker-trigger").addClass("a-Button a-Button--calendar");
As result we see Datepicker like below iamage
Change Year's Range
For example we need to limit the range of years between 1390 til 1400 Jalali.
//limit year range var yearRange = $( ".apex-item-datepicker" ).datepicker( "option", "yearRange" ); $( ".apex-item-datepicker" ).datepicker( "option", "yearRange", "1390:1400" );
After run this page we see a list of yeas.
Display Today Button
If we add below code we will able to display today button at the popup Datepicker
//add today button $( ".apex-item-datepicker" ).datepicker( "option", "showButtonPanel", true );
How to add time to date
First method when we want to add current time to date. It's child's play, we should use below function via TRIGGER BEFORE INSERT OR UPDATE of your table.(in this sample the field name is HIREDATE)
CREATE OR REPLACE FUNCTION ADD_TIME_TO_DATE(P_DATE IN DATE, P_TIME VARCHAR2 DEFAULT NULL) RETURN DATE IS /*----------------------------------- -- Author: Saeed Hassanpour -- Date: 2018/12/09 */----------------------------------- l_time VARCHAR2(10); BEGIN if P_TIME is null then select to_char(sysdate,'HH24:MI:SS') into l_time from dual; else l_time := P_TIME; end if; return To_Date(To_Char(P_DATE,'YYYY/MM/DD')||' '||l_time,'YYYY/MM/DD HH24:MI:SS'); END; / :NEW.HIREDATE := ADD_TIME_TO_DATE(P_DATE => :NEW.HIREDATE);
Next sometimes we need to add manually time to date, in this case it's better to add a new field to our table (in this sample the field name is HIRETIME) because when page loads the time field display their value so we could change the our time and save at date field.
Only changes above code in trigger with this:
:NEW.HIREDATE := ADD_TIME_TO_DATE(P_DATE => :NEW.HIREDATE , P_TIME => :NEW.HIRETIME);
I hope this helps.
No comments :
Post a Comment