querysting binding error when using ServiceStack version 4.0.34 and OrmLiteCacheClient - servicestack

We're getting an "unable to bind to request" when calling a service with the following querystring:
/SomeService?playerid=59326&fromdate=4-1-2014&todate=12-11-2014
We have been using this querysting format for awhile now.
The problem is some either a change in 4.0.34, or something in the OrmLightCacheClient, which we had turned off for awhile and only just recently turned it back on.
If I change the dates to following format, it seems to work.
/SomeService?playerid=59326&fromdate=2014-4-1&todate=2014-12-31.
We can roll with the changed querystring date format for now, but wanted to report the error.

When supplying a date only (i.e. doesn't include a time) it should be unambiguously defined using the YYYY-MM-DD format.

Related

Issue of Reading and Converting Date of Google Calendar Events when language is set to Arabic in C#

I am Using Google APis .net client library to read calendar events.
I have following line of code
newRow["Start"] = pEventItem.Start.DateTime.HasValue ?
Convert.ToDateTime(pEventItem.Start.DateTime) : Convert.ToDateTime(pEventItem.Start.Date);
Where PEventItem is of type Google.Apis.Calendar.v3.Data.Event and NewRow[...] is of type DataRow. The Value of pEventItem.Start.Date is "2019-06-24" (as seen in debug window)
The above line of code works perfect, But fails when UI language / Culture is set to Arabic (SaudiArabia) The same Convert.ToDateTime throws error "String was not recognized as a valid DateTime".
btw, How i am changing the UI language is as below for your information.
Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo(ChangeLanguageTo);
Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(ChangeLanguageTo);
I tried to set 2nd parameter of the Convert.ToDateTime function in an hope that it will convert date correctly...
CultureInfo enUsCulture = new CultureInfo("en-us");
newRow["Start"] = pEventItem.Start.DateTime.HasValue ? Convert.ToDateTime(pEventItem.Start.DateTime, enUsCulture) : Convert.ToDateTime(pEventItem.Start.Date, enUsCulture);
Well Now it does not throw exception, but the returned date is incorrect. value retuned is {21/10/40 12:00:00 ص}
while The actual date pEventItem.Start.Date is "2019-06-24"
I also tried invariant culture also, but result is same, converted date is wrong. What could be the issue?
Regards
There are a few things going on here.
Firstly, if you use EventDateTime.DateTime (e.g. via pEventItem.Start.DateTime) you don't need to call Convert.ToDateTime, because that's already a DateTime?... you can just take the Value property to get a DateTime from a DateTime?. However, I should warn that that can perform time zone conversions that you may not want. (We can't fix the library to avoid those, as it would be a breaking change.) Instead, you may want to parse EventDateTime.DateTimeRaw, which is the original string value returned by the API.
When parsing, I'd suggest using the invariant culture using CultureInfo.InvariantCulture (instead of creating an en-US culture), and parse using DateTime.ParseExact, specifying the format you expect based on whether you're parsing a date or a full date/time.
In terms of "the returned date is incorrect" - I believe that's really just the formatted value that's using the default culture, including the calendar system. We can see that at play in the code below, which constructs the DateTime directly (so can't be affected by any text parsing etc). When formatted using the invariant culture, it shows as 2019-06-24, but when formatted with ar-SA, it shows as "1440-10-21" due to the default calendar system for that culture being System.Globalization.UmAlQuraCalendar:
// Note: when a calendar system is not specified,
// it's implicitly Gregorian.
DateTime date = new DateTime(2019, 6, 24);
Console.WriteLine(date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
Console.WriteLine(date.ToString("yyyy-MM-dd", new CultureInfo("ar-SA")));
So what you're seeing in the debugger is the correct date - but formatted in a way you weren't expecting.

momentjs endOf('month') does not deliver last day of month

When I invoke the following code
moment('2020-01-01T00:00:00Z').endOf('month').utc().format()
I get the result
'2020-01-01T07:59:59Z'
when I would have expected to see
'2020-01-31T23:59:59Z'
Is this a bug or am I not using the API correctly?
I think the problem is you used endOf before you convert the Date in UTC.
You pass this Date : 2020-01-01T00:00:00Z but the browser understand it with your timezone so the "real date" is 2019-12-31T15:00:00Z.
So you must convert it to UTC first and then proceed your change/call/etc.
So, I tried that and it worked ! Tell me if the problem persist.
moment('2020-01-01T00:00:00Z').utc().endOf('month').format()

VBF syntax for SSRS expression cannot figure out proper construct

looking for help on what should be a very basic function. I am trying to get a SUM of a specific value, however I do not seem to get the syntax correct.
Here is what I have
=Sum(Fields!PriorYearSalesDollars.Value - Sum(Fields!PriorYearCost.Value
+Sum(Fields!PriorYearFrtCost.Value)))
However I get an error when trying to sum. Is there another way to test this also? Each time I modify the expression I then have to save the report and upload to the report server and test again. If I do it through the preview function in visual studio it throws a generic error on the whole report. When running from report server, just this specific column shows #Error
This is the syntax that works after FIRST changing the column format to numbers where I accidentally did it as currency first. Not sure why currency didn't work, but this is correct.
=Sum(Fields!PriorYearSalesDollars.Value) - (Sum(Fields!PriorYearCost.Value) + Sum(Fields!PriorYearFrtCost.Value))

Node.js - Oracle DB and fetchAsString format

I am stuck on a problem and I am not sure what is the best way to solve it. I have a date column that I want to select and I want to fetch it as a string. Which is great, node-oracledb module has this option with fetchAsString mehotd. But it fetches the date like this for example 10-JAN-16 and I want to fetch it like this 10-01-2016. Is there a way to do that from the node-oracledb module, or I should modify the date after I get the result from the query?
UPDATE: I mean solution without to_char in the query and without query modifications
Check out this section of my series on Working with Dates in JavaScript, JSON, and Oracle Database:
https://dzone.com/articles/working-with-dates-using-the-nodejs-driver
The logon trigger shows an example of using alter session to set the default date format. Keep in mind that there is NLS_DATE_FORMAT, NLS_TIMESTAMP_FORMAT, NLS_TIMESTAMP_TZ_FORMAT.
I only show NLS_TIMESTAMP_TZ_FORMAT because I convert to that type in the examples that follow as I need to do some time zone conversion for the date format I'm using.
Another way to set the NLS parameters is to use environment variables of the same name. Note that this method will not work unless you set the NLS_LANG environment variable as well.

bug in primefaces calendar timepicker?

I have this calendar with time picker on my page:
<p:calendar value="#{addTaskBacking.currentTask.deadline}" mode="inline"
pattern="dd-MM-yyyy HH:mm" mindate="01-09-2013 00:00"/>
When I set the pattern: dd-MM-yyyy without the time everything is added correctly, but when I change to: dd-MM-yyyy HH:mm I get this error:
j_idt10:j_idt12: '9-04-2014' could not be understood as a date and time.
This is when I set the inline mode, when I set the popup is all ok.
I have primefaces_v4.jar. I check this side http://forum.primefaces.org/viewtopic.php?f=3&t=22982 but i can't find any solution
Edit:
It look like all depends of mode atribute of p:calendar. If i have default popup mode everything it's fine (like in example on http://primefaces.org/showcase/ui/calendarTime.jsf. But when I change to inline mode i get this error:
cal:inlineCal: '13-04-2014' could not be understood as a date and time. Example: 13-04-2014 15:16
PrimeFaces uses SimpleDateFormat by default unless you override the formatter.
http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
EDIT
Your pattern will work if you change your mindate attribute to be the same as your pattern..
IE: You can't have a pattern dd-MM-yyyy HH:mm when you have a mindate="01/09/2013"
Change your mindate to - 01-09-2013
EDIT 2
AFter debugging a fair bit you're right, there seems to be a bug when setting the inputValue field in javascript prior to being sent in the POST to the server to even use the pattern converters...
I got it all working recompiling the code with the following changes:
Line 129 in calendar.js (gets merged into primefaces.js) var newDate = this.value;
Basically at the moment it tries to do a formatDate on the input which is fine cause its the same date format split ie, dd/mm/yy etc.. but it totally skips 'time' being attached can't use parseDatetime as it does an entire object time, which should be don eon the java side as you just build the object.
this.value is what you want regardless to be sent back in the post which is what it does for _self.cfg.popup (it doesn't even set the input val because its already there!...
I'll raise an issue with PF
"Raised Issue 6790 on the PrimeFaces Issue Tracker"

Resources