How can I compare and check date of program and the system date in MVS 2012 Coded UI test? - date

I am trying to compare and check the date if it is today's date or not in a spesific program. I tried to use assertion method but when I use it the time will remain same if you try it next day. The main problem that I need to know when open a page from program It should be today's date and should be passed. if you know already anything about it please let me know also :)
Thanks yo!

Use System.DateTime.Now.ToString("yyyy-MM-dd") as one argument of the assertion. You may need to use a different format rather in the ...ToString() method. The exact format depends on how the date is shown on the screen.

This could be done using "StringAssert" to verify that your programs date string contains today's date string, while ignoring the time:
var programDateString = "7/25/2016 12:00:00"; //this is an example of your date retrieved from the application with time included
var todaysDate = System.DateTime.Today.ToShortDateString(); //short date string
StringAssert.Contains(programDateString, todaysDate);

Related

DateTime in Flutter

I was importing internationalization for my app but I have a problem where I parse my String but it only returns the date and not the time. When I change the phone language, my format for the Date changes but my Time isn't showing.
This is when it is EN_US
This is when it is EU(German)
That works well but my time format is missing...
This is the default String from the API:
Here is the code:
/// I set a variable that calls the locale of the phone language and changes according to the phone preference
final f = DateFormat.yMd(Localizations.localeOf(context).languageCode);
/// where I dispay time and date but only date is shown in the pictures above
Text('Time and date: ${f.format(DateTime.parse(apicall.dateCreated))}');
My questions are: How do I show the time and how can I swap between showing the Time first then the Date, and opposite, if I want to show the Date first then the Time? (example 18-May-21 11:10h and if I want to do this 11:10h 18-May-21)
Thanks in advance for the help!
I suppose you should use DateFormat.jm().add_yMd(): this will show time first and then date. To swap it just use DateFormat.yMd().add_jm()
More info here

vb6 error 380 Datepicker, bust just in certain dates

Im having a problem with a datepicker on vb6, but this jus happen on certain dates, for example 31/01/2017, but with another dates it works fine.
I appreciate the help
This almost certainly has to do with how you are setting the date in the control.
For instance if the control's value is ANY month that does not have 31 days then you will get that error. Trying to set the control to 31/02/2017 would cause an error 380.
There are two approaches you can take to fix this.
Reverse the order you set the date components.
dtFecha.Year = Year(fcsAux.Fields("xf3ch4"))
dtFecha.Month = Month(fcsAux.Fields("xf3ch4"))
dtFecha.Day = Day(fcsAux.Fields("xf3ch4"))
Set the Value property instead of the date components. dtFecha.Value = "31/02/2017"
dtFecha.Value = rcsAux.Fields("xf3ch4").Value
The first approach ensures the month is always appropriate for the day. The second approach sets the entire value at one shot and should be a valid date.

Format date and add month to it

I'm currently working with embarcadero c++, this is the first time I'm working with it so it's completely new to me.
What I'm trying to achieve is to get the current date, make sure the date has the "dd/MM/yyyy" format. When I'm sure this is the case I want to add a month to the current date.
So let's say the current date is 08/18/2016 this has to be changed to 18/08/2016 and then the end result should be 18/09/2016.
I've found that there is a method for this in embarcardero however I'm not sure how to use this.
currently I've only been able to get the current date like this.
TDateTime currentDate = Date();
I hope someone will be able to help me out here.
I figured it out.
After I've searched some more I found the way to use the IncMonth method on this page.
The example given my problem is as follows:
void __fastcall TForm1::edtMonthsExit(TObject *Sender)
{
TDateTime StartDate = edtStartDate->Text;
int Months = edtMonths->Text.ToInt();
TDateTime NextPeriod = IncMonth(StartDate, Months);
edtNextPeriod->Text = NextPeriod;
}
After looking at I changed my code accordingly to this
TDateTime CurrentDate = Date();
TDateTime EndDate = IncMonth(CurrentDate, 1);
A date object doesn't have a format like "dd/MM/yyyy". A date object is internally simply represented as a number (or possibly some other form of representation that really isn't your problem or responsibility).
So you don't have to check if it's in this format because no date objects will ever be in this format, they simply don't have a format.
You will have to do additions/subtractions on the Date object that the language or library gives you, THEN (optionally) you can format it to a human-readable string so it looks like 18/08/2016 or 18th of August 2016 or whatever other readable format that you choose.
It might be that the TRANSFER of a date between 2 systems is in a similar format, but then formatting the date like that is entirely up to you.
As for how to do that, the link you posted seems like a possible way (or alternatively http://docwiki.embarcadero.com/Libraries/Berlin/en/System.SysUtils.IncMonth), I'm afraid I can't give you an example as I'm not familiar with the tool/language involved, I'm just speaking generically about Date manipulations and they should ALWAYS be on the raw object.

Export Calendar Date to spreadsheetout - Time Stripped off - Google Script

I am using Google Script to export some calendar events to a spreadsheet; the relevant portion of my script is below:
var details=[[mycal,events[i].getTitle(), events[i].getDescription(), events[i].getLocation(), events[i].getStartTime(), myformula_placeholder, ('')]];
var range=sheet.getRange(row,1,1,7);
range.setValues(details);
This code works but the "time" that is put into the spreadsheet is a real number of the form nnnnn.nn. On the spreadsheet itself the date looks great using the integer to the left of the decimal (eg 10/15/2017) but the decimals are part of the value and therefore are part of the spreadsheet value.
My script drops the data into a sheet in my workbook, and another sheet reads the rows of data with the above date types, looking for specific date info from the other sheet using the match function (for today()). That would work fine if I could get rid of the decimals.
How can I use what I have above (if I stray far from what I have found works I will be redoing hours of work) but adding just what is needed to only put into the output spreadsheet the whole number portion so I have a pure date that will be found nicely by my match function using today()?
I have been digging, but errors abound in trying to put it all together. "Parse" looked like a good hope, but it failed as the validation did not like parse used within getStartTime. Maybe I used it in the wrong manner.
Help would be appreciated greatly.
According to the CalendarApp documentation, getStartTime() generates a Date object. You should be able to extract the date and time separately from the date object:
var eventStart = events[i].getStartTime(); // Returns date object
var startDate = eventStart.toDateString(); // Returns date portion as a string
var startTime = eventStart.toTimeString(); // Returns time portion as a string
You could then write one or both of these to your spreadsheet. See the w3schools Javascript Date Reference for more information:
http://www.w3schools.com/jsref/jsref_obj_date.asp
If you If you want to specify the string format, you can try formatDate in the Utilities service:
https://developers.google.com/apps-script/reference/utilities/utilities#formatdatedate-timezone-format
You could just use the Math.floor() function
http://www.w3schools.com/jsref/jsref_floor.asp
which will round the real number to an integer. Your line would then read:
var details=[[mycal,events[i].getTitle(), events[i].getDescription(), events[i].getLocation(), Math.floor(events[i].getStartTime()), myformula_placeholder, ('')]];

momentjs: Get invalid date when trying to get current date with moment()

Hi Im using firefox and CoffeeScript in an app, I want to get current date with momentjs using default method moment() however when I debug the code I seeinvalid Date, it is very weird, this is my code:
questionStarts =
started_at: moment()
running: true
Then later in my code I create another object and add the property
answer = {}
answer.started_at = questionStarts.started_at
But when I check answer.started_at I get back Invalid date any idea?
Moment has an alternate constructor for strange dates. Since I can't see the value of answer.started_at in your code, I can only guess about how to solve your problem.
Consider for example some strange date format like 08.16.2015 00:00:00. Trying to construct a moment object from it will give the same error you have, Invalid date. That's what happens if you tried constructing my example like this:
//this doesn't work, throws Invalid date message
var ex = moment('08.16.2015 00:00:00');
So, to fix my problem, I give another constructor that informs Moment of the strange date format.
//this does work, however
var ex = moment('08.16.2015 00:00:00', 'MM.DD.YYYY hh:mm:ss');
Now, I can use ex as a typical moment object taking advantage of moment's other methods such as format() diff() and isBetween().