Get the previous month from today's date - lwuit

Is there a way in lwuit1.4 to get the the last month from todays date? I tried using the add method, but it is not there in lwuit's calendar api.

That's unrelated to LWUIT, its the java.util.Calendar class from CLDC which is missing the add method. It does have the set method so you you can code something like that yourself. See the code for LWUIT's Calendar class where the arrows allow navigating between months.

Related

Set datepicker for one year from today in Cypress test

I am creating an acceptance test in Cypress that will run regularly, and I need that it enters the date from the datepicker (React, if it is important) as 1 year 1 month and 1 day from the day of creating the object (article). E.g. Today is April 22, 2020, and I want to get May 23, 2021 in the article created today, and tomorrow it would give the value of May 24, 2021 etc. Could anyone share any ideas of setting this up? I honestly googled and I have no ideas myself because I'm quite new to Cypress and feel more or less confident only in pretty straightforward things. :)
I'd guess that most date pickers will have an input element where the date can be typed.
Presuming the app uses a library date picker (so you don't need to test the picking of the date via button clicks), you can target that element and use the Cypress .type() command to enter the future date.
For example, the Material UI date picker docs has this input element
<input aria-invalid="false"
id="date-picker-inline"
type="text"
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd"
value="08/18/2014">
so the steps would be something like
cy.visit('https://material-ui.com/components/pickers');
const targetDate = Cypress.moment()
.add(1, 'year')
.add(1, 'month')
.add(1, 'day')
.format('MM/DD/YYYY') // adjust format to suit the apps requirements
cy.get('input[id="date-picker-inline"]')
.clear()
.type(`${targetDate}{enter}`) // presume you need the enter key to trigger an event
Ref: Cypress.moment
This method was deprecated. You can use this method;
//click the date picker
cy.get('#datepicker').click();
//choose previous month
cy.contains('Prev').click();
//choose next month
cy.contains('Next').click();
//choose date 24
cy.contains('24').click();

How to get value from date picker in katalon studio

I want to get value from date picker (get date from date picker and stored in to variable) in katalon.
I would suggest using the Java programming language and get your datepicker Date from Java code. Do not forget to include the import statement at the top of the test case for the java.util... library you get the datepicker from.

Silverstripe calendar picker to not show past dates

Is there a way to set the calendar picker in Silverstripe to not be able to select dates that are in the past?
As far as I can tell it uses the jQuery DatePicker but I am unsure how to restrict the past dates.
DateField::create("Date","Date")
->setAttribute('placeholder','eg 2017-01-01')
->setConfig('showcalendar', true),
You can pass configuration options to the datepicker:
DateField::create("Date","Date")
->setConfig('showcalendar', true)
->setConfig('min', date('Y-m-d'))
->setDescription('')
->setAttribute('data-number-of-months', 3);
->setConfig('min', date('Y-m-d')) tells jQueryUI picker to use a minimal date (today). With data-attributes you can also pass other configuraton to the picker, in the above case it shows three months at once. This will be passed to datepicker config.
Note that the datepicker camel case config "numberOfMonths" has to be written with hyphens like 'data-number-of-months'.
See also datepicker configuration

zebra datepicker direction - past up to certain date

I want to set up Zebra datepicker plugin in a way that it has enabled all past dates up to certain specified date. I found out this stackoverflow post that explains how to do that if that border date is today. But, if the border date is lets say 1 month in the past or so, how should I define the "direction" option?
So basically I want to restrict date selection from the "beginning of time" up to some specified date.
Thank you
As you can see they described it in the documentation. Try out this code:
$('#datepicker-example5').Zebra_DatePicker({
// remember that the way you write down dates
// depends on the value of the "format" property!
direction: ['2012-08-01', '2012-08-12']
});
The example is listed in topic "Demos" (Sub-Topic 5) here: http://stefangabos.ro/jquery/zebra-datepicker/

Add a class depending on date

I have a standard link that I would like to add a class to depending on a date. Is this possible using Javascript/JQuery?? My code at the moment is simply this:
<div id="box1">1</div>
So if the date is actually 1st July I would like the class to change to "current" and if the date is past 1st July (2nd, 3rd, 4th etc) then the class to be "active".
I'm thinking there maybe a way to do this via Javascript or JQuery or possibly PHP. I'm not a developer so really not too sure. Any help would be appreciated. Thank you in advanced.
Something like this:
Do your date logic
Remove the class: $("#box1 a").removeClass('disabled');
Then add class: $("#box1 a").addClass('active');