Hi All, |
Re: Date comparison logic inverted?
Whoooa - that is weird. Logic my results your results (d1 == d2) false true (d1 != d2) true false (d1 < d2) true false (d1 > d2) false false //match (d1 <= d2) true true //match (d1 >= d2) false true
Paul Miller
|
Re: Date comparison logic inverted? SystemAdmin - Sun Jan 23 19:21:27 EST 2011
Whoooa - that is weird. Logic my results your results (d1 == d2) false true (d1 != d2) true false (d1 < d2) true false (d1 > d2) false false //match (d1 <= d2) true true //match (d1 >= d2) false true
Paul Miller
Hello,
Date d1 = date("2 November 2010")
Date d2 = date("3 November 2010")
print "date=" d1 "\n"
print "date=" d2 "\n"
print (d1 == d2) "\n"
Date d1 = date("2/11/2010")
Date d2 = date("3/11/2010")
print "date=" d1 "\n"
print "date=" d2 "\n"
print (d1 == d2) "\n"
Date d1 = "02 November 2010" Date d2 = "03 November 2010" print "date=" d1 "\n" I have : date=02 November 2010 date=03 November 2010 false print "date=" d2 "\n" print (d1 == d2) "\n"
|
Re: Date comparison logic inverted?
When parsing string dates (and also when printing dates) DOORS will try to use the default locale, so you should ALWAYS pass the format identifier! The solution to your riddle is, that the date will be passed to (null), therefore you get the equality.
{
Date d1 = date("2 November 2010", "dd MMMM yyyy")
Date d2 = date("3 November 2010", "dd MMMM yyyy")
print (d1 == d2) "\n"
print (d1 != d2) "\n"
print (d1 < d2) "\n"
print (d1 > d2) "\n"
print (d1 <= d2) "\n"
print (d1 >= d2) "\n"
}
{
Date d1 = date("2 November 2010")
print intOf d1
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Date comparison logic inverted? print "null dates: " (null d1) "\t" (null d2) "\n" print "D1: \t" stringOf(d1) "\n" print "D2: \t" stringOf(d2) "\n" It prints null, then aborts at the stringOf command. Null Dates will produce your results. Mathias will no doubt survive the nulls and print the Dates as those are legal date formats for him So "2 November 2010" is illegal for you and I but not for Mathias; no doubt one of those "Anglo" things. I use format "2011-Jan-21" and "2011-01-21" because its unambiguous and I cannot stand the US format; but those are illegal also, so I wrote my own converter. The "-Jan-" in reports that will not be sorted Alpha, "-01-" in file names and columns that may be sorted.
|
Re: Date comparison logic inverted? PDU - Mon Jan 24 02:01:41 EST 2011
Hello,
Date d1 = date("2 November 2010")
Date d2 = date("3 November 2010")
print "date=" d1 "\n"
print "date=" d2 "\n"
print (d1 == d2) "\n"
Date d1 = date("2/11/2010")
Date d2 = date("3/11/2010")
print "date=" d1 "\n"
print "date=" d2 "\n"
print (d1 == d2) "\n"
Date d1 = "02 November 2010" Date d2 = "03 November 2010" print "date=" d1 "\n" I have : date=02 November 2010 date=03 November 2010 false print "date=" d2 "\n" print (d1 == d2) "\n"
|
Re: Date comparison logic inverted? LIMoon - Tue Jan 25 05:15:16 EST 2011 |
Re: Date comparison logic inverted? LIMoon - Tue Jan 25 05:17:44 EST 2011 |
Re: Date comparison logic inverted? Mathias Mamsch - Mon Jan 24 07:55:30 EST 2011
When parsing string dates (and also when printing dates) DOORS will try to use the default locale, so you should ALWAYS pass the format identifier! The solution to your riddle is, that the date will be passed to (null), therefore you get the equality.
{
Date d1 = date("2 November 2010", "dd MMMM yyyy")
Date d2 = date("3 November 2010", "dd MMMM yyyy")
print (d1 == d2) "\n"
print (d1 != d2) "\n"
print (d1 < d2) "\n"
print (d1 > d2) "\n"
print (d1 <= d2) "\n"
print (d1 >= d2) "\n"
}
{
Date d1 = date("2 November 2010")
print intOf d1
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Sorry to be opening this topic again, but I tried running the commands above recommended by Mathias and the results were still inverted. When I appended Louies code I go errors: -E- DXL: <Line:17> incorrect arguments for function (null) I have a Spanish PC and tested on DOORS 8.3 and 9.5.2 I had to modify it as follows to get it to work
{
Date d1 = date("2-11-2010",userLocale, "dd-MM-yyyy")
Date d2 = date("3-11-2010",userLocale, "dd-MM-yyyy")
print (d1 == d2) "\n"
print (d1 != d2) "\n"
print (d1 < d2) "\n"
print (d1 > d2) "\n"
print (d1 <= d2) "\n"
print (d1 >= d2) "\n"
}
{
Date d1 = date("2 November 2010")
print intOf d1
}
|
Re: Date comparison logic inverted? MyDeveloerWorks - Fri Mar 28 06:13:56 EDT 2014 Sorry to be opening this topic again, but I tried running the commands above recommended by Mathias and the results were still inverted. When I appended Louies code I go errors: -E- DXL: <Line:17> incorrect arguments for function (null) I have a Spanish PC and tested on DOORS 8.3 and 9.5.2 I had to modify it as follows to get it to work
{
Date d1 = date("2-11-2010",userLocale, "dd-MM-yyyy")
Date d2 = date("3-11-2010",userLocale, "dd-MM-yyyy")
print (d1 == d2) "\n"
print (d1 != d2) "\n"
print (d1 < d2) "\n"
print (d1 > d2) "\n"
print (d1 <= d2) "\n"
print (d1 >= d2) "\n"
}
{
Date d1 = date("2 November 2010")
print intOf d1
}
Just a hunch, but if you are on a Spanish machine, try using "Noviembre" instead of "November" |
Re: Date comparison logic inverted? Tony_Goodman - Fri Mar 28 10:53:50 EDT 2014 Just a hunch, but if you are on a Spanish machine, try using "Noviembre" instead of "November" That is, the date() function is returning null because it ..err.. your Locale doesn't understand the string date format you are using. easily enough checked, just print the dates after calculating them. |
Re: Date comparison logic inverted? llandale - Fri Mar 28 12:00:31 EDT 2014 That is, the date() function is returning null because it ..err.. your Locale doesn't understand the string date format you are using. easily enough checked, just print the dates after calculating them. Hi Tony, Louie, thanks for the responses,,, I am not at my DOORS desktop now so I will answer as best I can. Regarding the language, there is more to the syntax (11 de noviembre de 2014). I printed the dates after calculating them and by trial and error I found that the format Date d1 = date("2-11-2010",userLocale, "dd-MM-yyyy") worked. The real issue I am having and I have this opened in the General DOORS forum, is that my Locale conflicts with the the Locale chosen by the History Date attribute. Unless I force my Locale to conform to the one that that the Date Type in History uses, I cant get it to work. |
Re: Date comparison logic inverted? MyDeveloerWorks - Fri Mar 28 13:01:44 EDT 2014 Hi Tony, Louie, thanks for the responses,,, I am not at my DOORS desktop now so I will answer as best I can. Regarding the language, there is more to the syntax (11 de noviembre de 2014). I printed the dates after calculating them and by trial and error I found that the format Date d1 = date("2-11-2010",userLocale, "dd-MM-yyyy") worked. The real issue I am having and I have this opened in the General DOORS forum, is that my Locale conflicts with the the Locale chosen by the History Date attribute. Unless I force my Locale to conform to the one that that the Date Type in History uses, I cant get it to work. Over my head here, but I would suppose the following would not care one iota about "Locales"
The following I suppose WOULD cause Locale issues:
-Louie |