pickdate.js parameters and monthPicker - datepicker

I'm trying to suit well this plugin pickadate.js v3.3.1 but I'm facing some difficulties.
First, I need to restrict selection of only future dates, 3 months from today's date. The docs didn't help me much so tried to do it this way. But it's not working.
Second, can I change this to a MONTH PICKER only? I need this for a Credit Card Expiry date field input.
The documentation isn't very great, But I guess being a new plugin I can use some good help of geeks here.
<script>
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+3;
$('#pickdate').pickadate({
// Escape any “rule” characters with an exclamation mark (!).
format: 'mmm dd , yyyy',
formatSubmit: 'yyyy/mm/dd',
hiddenPrefix: 'prefix__',
hiddenSuffix: '__suffix',
min: new Date(),
max: mm
//min: new Date(),
//max: (new Date() + 10)
})
$('#picktime').pickatime();
</script>

From the docs:
If dateMax or dateMin is an integer, it represents the relative number
of days till the min or max date.
I couldn't find any mentioning in the docs of a month picker. Why not use a standard dropdown ()?
What could prove to be of use to you with regards to range, again from the docs, is:
dateMin and dateMax can be either
an array representing a date ([ yyyy, mm, dd ])

Related

Calculating days between two dates with Flutter

I want to develop a small Flutter app that calculates the number of days between two dates, using the following steps :
Ask the user to type the first date (Turkish notation; with whitespaces: "dd mm yyyy")
Ask the user to type the second date.
After that the program should calculates the number of days between the two dates and display it.
Given dateText and dateText2, this will give you the days between:
var dateArray = dateText.split(' '); // [d, m, y]
var date = new DateTime(int.parse(dateArray[2]), int.parse(dateArray[1]), int.parse(dateArray[0]));
var dateArray2 = dateText2.split(' ');
var date2 = new DateTime(int.parse(dateArray2[2]), int.parse(dateArray2[1]), int.parse(dateArray2[0]));
var daysBetween = date2.difference(date).inDays;
print(daysBetween); // 365

Can we input different date inputs while running the Automation script each time

I am using protractor 5.2.2. We have a requirement of creating a module with unique date so that i cannot create a module with already used date.So when i am running the script , i have to pass different date each time.How we can choose random date in automation.Thanks in advance.
I recommend using chancejs.
var Chance = require('chance'),
chance = new Chance();
console.log(chance.integer({ min: -2, max: 2 }));
would return either -2, -1, 0, 1, or 2.
Please take a look at the chancejs homepage http://chancejs.com/
Below example gives a data between these two years
var Chance = require('chance');
var chance = new Chance();
let bounds = {
min: chance.date({ year: 1983 }),
max: chance.date({ year: 1989 })
}
let date = chance.date(bounds)
console.log(date);
I got 1987-01-21T19:31:32.851Z
1.Random dates in JAVA
Generate random date of birth
if you are using the Excel as data provider
Use the Excel formula's like
=today();
=now();
if you are using java or other languages
use
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyyHH:mm:ss");
Date date = new Date();
C#
https://stackoverflow.com/questions/6817266/get-current-date-only-in-c-sharp
MomentJS is a good option that allows you to set time easily off the current time.
Examples:
moment.format('MM/DD/YYYY'); //gives you current date in mm/dd/yyyy format
moment.format('MM-DD-YYYY'); //current date in mm-dd-yyyy format
moment.add('5','days').format('MM/DD/YYYY'); gives you date 5 days from now

Google Charts Horizontal Axis wrong date

In the pic above, the horizontal axis is a day ahead of the actual values. Very new to google charts and cant figure out what the issue could be. I have verified the data being passed to the chart is the 14th, 15th, and 16th.
google.visualization.ComboChart
Found an answer to this. The problem was javascript subtracting a day from the date range.
Here is how I was initially setting the date:
var dt = new Date($(child).text());
dt.setDate(dt.getDate());
addData.push(dt);
Solution
var year = parseInt($(child).text().split("-")[0]);
var month = parseInt($(child).text().split("-")[1])-1;
var day = parseInt($(child).text().split("-")[2]);
var dt = new Date(year, month, day);
addData.push(dt);

nvd3 (d3.js) date format returns incorrect month

My data looks like this:
[{ x="2013-06-01", y=3}, { x="2013-07-01", y=7 }, { x="2013-08-01", y=3 }]
Chart x-axis is formatted as so:
chart.xAxis
.axisLabel('Date')
.tickFormat(function(d) { return d3.time.format('%b %Y')(new Date(d)); })
;
%b returns May, Jun, July respectively for the dates 2013-06-01, 2013-07-01, 2013-08-01
Why is it returning the previous month, and how can I fix it?
EDIT: If the date is formatted as 2013-06-02, it will return the correct month... does someone know what is happening to cause this?
#Amelia is correct it's because of timezone difference and because Date defaults to 24:00:00 if you don't specify a time. So, in case of EDT, which is -4:00, you lose 4 hours which puts you in the previous day (May 31 2013 20:00:00) and because the days in your dates are 01, this puts you in the previous month.
To bypass this you could append a time to your date if that is allowable in your case.
chart.xAxis
.axisLabel('Date')
.tickFormat(function(d) {
d = d.split('-')
// Create new date by using new Date(year, month, day, hour, second, ms)
// Subtracting 1 is necessary since Javascript months are 0 - 11.
return d3.time.format('%b %Y')(new Date(d[0], +d[1] - 1, d[2], 12, 0, 0));
});
Here is a working Fiddle

GWT DateTimeFormat returns the wrong date

I have the following code
String test = "21/04/2013";
fmt = DateTimeFormat.getFormat("MM/dd/yyyy");
Date dateTest = fmt.parse(test);
Window.alert(fmt.format(dateTest));
And the alert box shows the date
09/04/2014
instead of
21/04/2013
Why?
As others already say, it's because of your pattern. What they don't say is why it behaves that way.
When parsing 21/04/2013 as MM/dd/yyyy, DateTimeFormat will decompose the date as:
Month Day of month Year
21 4 2013
and it'll then adjust things to make a valid date. To do that, the Month part is truncated at 12 (so that temporary date is Dec 4th, 2013) and the remainder (21 - 12 = 9) is then added, leading to Sept. 4th 2014, which according to your format displays as 09/04/2014.
You wanted to show 21/04/2013 but the format was MM/dd/yyyy.
It should be dd/MM/yyyy
So change it like this:
String test = "21/04/2013";
fmt = DateTimeFormat.getFormat("dd/MM/yyyy");
Date dateTest = fmt.parse(test);
Window.alert(fmt.format(dateTest));
You're reversing day and month.
String test = "21/04/2013";
fmt = DateTimeFormat.getFormat("dd/MM/yyyy");
Date dateTest = fmt.parse(test);
Window.alert(fmt.format(dateTest));