Less if else conditions in angularjs - angularjs

I have 2 main dates : MainFrom and MainTo Depending on these , I have set validations for my work experience date validations in angularjs(I know, it is old but the proejct was written in this version). I can add from and to experience dates.Validation needed:
Main From date > Main To date
other Experince dates should be between these dates.
Other work experience to date should be greater than from date.
I have written lot of conditions to check these.
Could someone suggest less lines of code?

to go with the trend these day try moment in you angularjs app,
first include moment js in your project, the lib will help you in all validations and checks related to dates.
for eg in your cases validation check will something like this:
Main From date > Main To date :
if(moment(Main From date).isAfter(Main To date))
other Experince dates should be between these dates. :
loop on every date
if(moment(other Experince dates).range(startDate, endDate);)
Other work experience to date should be greater than from date.
if(moment(to date).isAfter(Main from date))

Related

How to set min or max date limit in CakePHP form?

In my current date form input, I have the parameter:
'maxYear' => date('Y')
This lets me limit the max year to this year, but I also need to limit the date selection so users cannot select a date in the future. Using maxYear only allows limiting the year, but I also need months and days.
That's not something you can do with the Form Helper (or the HTML form options even if you'd wrote them manually).
The problem:
If you limit the month to say, 1-7 (if we're currently in July), the user would be unable to select the previous year of any of those months.
The solution:
Use JavaScript onchange validation. When the field(s) change date, check the selected date against your required date range, and give notification if it fails. (see jQuery's .change() documentation if you're using jQuery)
(Then verify on the back-end, as well of course, as JavaScript can easily be manipulated)

Codename One - days of month

I am trying to build a week view of the month with customized cells, so the Calendar class won't work for me.
I am having trouble knowing on which day the month starts. For example, January 1st was a Friday. Also, I need to know how many days a given month has.
Without telling me the exact code, can you tell me the variables or methods I could use for this?
Look at the actual code for the Calendar class here: http://github.com/codenameone/CodenameOne/
Just set java.util.Calendar to the right date then use the get method to get the day of the week.

Datefield compare and validate in Angularjs

I'm looking for a way to validate two input datefields in my form.
I have a start date and end date
and conditions to check are
1.start date should not be greater than end date
2.end date should not be less than start date.
I'm trying to create a directive, if there is already a solution, can you please share.

Mobiscroll datetime, remove all validation

I'm prototyping this date picker with a client. They are finding it very confusing that you need to pick year first before other months and days become available for selection (which is fair enough).
We do date validation on the backened anyway, so is there anyway to remove the disabling of invalid dates so the user can choose anything they want immediately, instead of following the required pattern of year -> month -> day selections.
I couldn't find anything in the docs.
This was resolved by not including maxDate, even if it was null

How to handle recurring holidays in Salesforce

In salesforce I can create recurring holidays and based on that in my apex class I want to check whether the current day is holiday or not.
This works fine with normal non recurring holiday. But when I create recurring holiday there is no way to find whether current date will fall on any of the recurring dates.
the holiday object's ActivityDate returns the start date of holiday.
Does anyone have checked the recurring holidays in past for salesforce?
Here is how i would approach this.
Create a function that will take parameters like RECURRENCESTARTDATE , RECURRENCEENDDATEONLY, RECURRENCETYPE, RECURRENCEINTERVAL, RECURRENCEDAYOFWEEKMASK, RECURRENCEDAYOFMONTH, RECURRENCEINSTANCE, RECURRENCEMONTHOFYEAR.
Then this function will loop from start date and for ever iteration it will increment value till date is > today or date is > RECURRENCEENDDATEONLY
in this loop you can check if today's == date calculated above.
once this function is ready pull out list of all recurring holidays.
and call above function on each list item.
let me know if you have any questions.

Resources