Select the current date and other date in the phpunit selenium? - selenium-webdriver

I making the date format using jquery in the text box.
And want to know how can i select the date in the input box .
How can i set the value of current date format in the phpunit selenium?

try to use the php date function
$startDate = date('Y-m-d');
$endDate = date('Y-m-d', strtotime("+30 days"));
$this->type('name=from_date',$startDate);
$this->type('name=to_date',$endDate);

Related

Lightning Flow Query

I am creating the lightning flow. In which, I need to provide the date in the 'field1' (Type : Date) in the screen component.
In the screen component, the 'field1' should only accept the date value which is in the range of 3years in the past of the current date and 2 years in the future of the current date.
For instance, if a user is entering the value in the 'field1' Date field on 5/13/2021 then the valid date range is between 5/13/2018 thru 5/13/2023.
Can anyone please guide/assist on how to achieve this.
Thanks in advance.
enter image description here
To create this date field you need to use following formula
IF(OR(
({!Accepted_Date} <= (DATE(YEAR({!$Flow.CurrentDate}) - 3,MONTH({!$Flow.CurrentDate}),DAY({!$Flow.CurrentDate}) - 1))), ({!Accepted_Date} >= (DATE(YEAR({!$Flow.CurrentDate}) + 2,MONTH({!$Flow.CurrentDate}),DAY({!$Flow.CurrentDate}) + 1)))
), false, true
)

Create current date in String format and parse to date as string in Apex

Goal:
I need to first create a String representing the current date.
Afterwards this String needs to be parsed and used to build an instance of the Date class.
Initial attempt:
In my test class I create a current date as a String input for my tested method in the following manner:
String inputDate = date.today().format(); // 13:28:15:378 USER_DEBUG [24]|DEBUG|17.3.2017
However, when I attempt to create an instance of a Date object like this:
Date dateFromInput = date.valueOf(inputDate);
I receive the following error:
13:28:15:398 FATAL_ERROR System.TypeException: Invalid date: 17.3.2017
Following code
((DateTime)Dob).format('YYYY-MM-dd')
Just Works
Date.format() will return string in current local date format of logged in user.
Date.valueOf needs input string in format yyyy-MM-dd HH:mm:ss in the local time zone.
Below should work:
String inputDate = date.today().format('**yyyy-MM-dd HH:mm:ss**');
Date dateFromInput = date.parse(inputDate);
In the documentation, there is a difference between the parse and valueOf Date methods that escaped me:
parse(stringDate)
Constructs a Date from a String. The format of the String depends on the local date format.
valueOf(stringDate)
Returns a Date that contains the value of the specified String.
What I wanted was the parse:
String inputDate = date.today().format(); /
Date dateFromInput = date.parse(inputDate);
You can try Moment.apex. Here is the link
Datetime dt = new Moment('2018/01/12 10:00:00', 'yyyy/MM/dd HH:mm:ss').toDatetime();

How to modify Drupal 7 events calendar week view to include Sunday?

I'm new to Drupal 7, and I have a problem where the events calendar week view doesn't show Sunday events, because the end date in the query is incorrect. Actually it only ever shows 6 days. How can I modify the query? How can I even find where it is generated?
Below is the query from the Events Calendar (Content) page. You can see that the start date comparison is ">= '2016-11-14 00:00:00" end date comparison is "<= '2016-11-20 00:00:00'", which doesn't retrieve events happening on Sunday. I need to change it to "<= '2016-11-20 23:59:59'".
Changing the first day of the week doesn't help, because it just shifts the six day time frame to start on Sunday, and misses events on both Saturday and Sunday.
SELECT field_data_field_event_date.delta AS field_data_field_event_date_delta, field_data_field_event_date.entity_id AS date_id_field_event_date, field_data_field_event_date.delta AS date_delta_field_event_date, node.nid AS nid, field_data_field_event_date.language AS field_data_field_event_date_language, field_data_field_event_date.bundle AS field_data_field_event_date_bundle, field_data_field_event_date.field_event_date_value AS field_data_field_event_date_field_event_date_value, field_data_field_event_date.field_event_date_value2 AS field_data_field_event_date_field_event_date_value2, field_data_field_event_date.field_event_date_rrule AS field_data_field_event_date_field_event_date_rrule, node.title AS node_title, 'node' AS field_data_field_event_date_node_entity_type, 'node' AS field_data_body_node_entity_type, 'node' AS field_data_field_event_cat_node_entity_type
FROM
{node} node
LEFT JOIN {field_data_field_event_date} field_data_field_event_date ON node.nid = field_data_field_event_date.entity_id AND field_data_field_event_date.entity_type = 'node'
WHERE (( (DATE_FORMAT(field_data_field_event_date.field_event_date_value2, '%Y-%m-%d %H:%i:%s') >= '2016-11-14 00:00:00' AND DATE_FORMAT(field_data_field_event_date.field_event_date_value, '%Y-%m-%d %H:%i:%s') <= '2016-11-20 00:00:00') )AND(( (node.status = '1') )))
ORDER BY field_data_field_event_date_field_event_date_value ASC
I would first check your regional settings asyou can change the First day of the week there and just resave the value there - possibly try ye olde on-and-off again, switch between monday and sunday. /admin/config/regional/settings
Secondly, have you checked the module itself for this issue? A patch may be posted under their issue queue.
If all else fails, you could use hook_views_query_alter in a custom module to modify the where clause of the query that is generated. I've written a blog post on this hook previously found here but basically you have all the components of the query so can alter what you need there. Eg.
// add the condition of greater than current timestamp
$date = gmdate('Y-m-d H:i:s');
$view->query->where[1]['conditions'][] = array(
'field' => 'field_mytimefield_value',
'value' => $date,
'operator' => '>='
);

Get month from datefield

I using Django-rest and I want to get month form Datefield in AngularJS.
My code is date = '2014-2-30' and I get month: var x = (new Date (Date.parse (date).getMonth().
But x = 1 and value of year = 114.
I read https://docs.angularjs.org/api/ng/filter/date but I can't do it. Would you give me example?
Django REST Framework should pass dates back to Angular in ISO 8601 format (yyyy-MM-dd), so there shouldn't be an issue parsing it on Angular's side.
{{ obj.date | date:"MMMM" }}
MMMM is the Angular date code for the full month (January-December). You can find other Angular date codes in the date filter documentation.

Valdiation From To date

I am developing Windows Form using vs2010 C#
I have 2 datetime pickers
1 is fromDatePicker and the other is ToDatePicker
I want to validate that the toDate is always after from date are the same day
eg if From:30/8/2010...To:16/8/2010
An error message is showed to user.
You can do comparisons on `DateTimes'
if (toDate < fromDate)
{
MessageBox.Show("To date is before from date");
}
If you're not worried about the time portion then use the Date property:
if (toDate.Date < fromDate.Date)
{
MessageBox.Show("To date is before from date");
}
Can you set a minimumDate property on your toDate control to the date on the fromDate control?

Resources