dojo/mvc/at doesn't return dijit/form/DateTextBox in format of constraints datePattern - dojo

This seem's to be a question often asked, but there doesn't seem to be an easy answer or an answer at all, so I risk a duplicate here, and ask again - I feel like having a puzzle with 4 pieces and don't manage to put them together:
I'm using a dojo date picker like this
<input data-dojo-type="dijit/form/DateTextBox"
data-dojo-props="constraints: { datePattern: 'yyyy-MM-dd'},
value: at(model, 'myDate')" />
The date picker displays the date in UI like I want, but the value that's assigned in model.myDate keeps being in ISO format - I'd need that to be in yyyy-MM-dd, too.
I know that I can use dojo.date.locale.format to post-process the value, but that would be after it is saved in model.myDate. I'd like to return the value in the correct format right away. Return value null if there's no input, return value undefined if there's no valid value, and return value in format yyyy-MM-dd when the given date is valid.
Maybe I can integrate that call to dojo.date.locale.format somehow? Something like .transform(..) or whatever is possible in dojo!?
I also read about overwriting the serialize method, but I don't see how and where to do that in here.
Any ideas or hint in the right direction? Many thanks in advance.

Hi just wondering if something like at(model, prop).transform(converterObj) helps: http://dojotoolkit.org/reference-guide/1.10/dojox/mvc/at.html#data-converter

Related

How do I get the right date format after using get text on the folder date?

I have tried everything that I can think of to get the right date format. Can anybody help with this RPA-problem in UiPath. I have used the 'get text' activity to get the folder date and after that tried to use the
Datetime.ParseExact(Str variable,"dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).
It gives me the error:
Assign: String was not recognized as a valid DateTime.
Your help is much appreciated.
edit: I have now sought help from a friend who figured it out. The error was in the string, which could not be seen, because there was an invisible character in the string that I extracted through 'get text' activity. The solution is in 2 steps:
assign another variable to the exact same date and use an if statement to find out if these two strings are equal and you will find out that they are not.
Now use a regex to capture only digits and slash/hyphen which will get rid of the invisible character.
Try to use "dd_MM_yyyy" instead of "dd/MM/yyyy".
The reason is because UiPath/VB.Net has a habit of using US date formatting even though you're using Culture Info...It's a real pain
Try this:
pDateString = "21/02/2020"
Assign a Date type variable = Date.ParseExact(pDateString,"dd/MM/yyyy",nothing)
Here we're telling the parser to use English format date...The Date type returned will be in US format but you can simply convert back to uk IF needed by using something like:
pDateString("dd/MM/yyyy")

jQuery Input Masks for datetime input using sql timestamp yyyy/mm/dd hh:mm:ss

I'm using Robin Herbot's jQuery Input Masks plugin on my project.
It's very good but I need sql timestamp mask: yyyy/mm/dd hh:mm:ss I don't konw if i'm doing something wrong but it seems datetime alias shows only hours and minutes.
I've tried some changes on mask but not successful.
Thanks.
I see the question is from long ago, I also came here while trying to learn jquery.inputmask.
Remember to always include what you have done (code sample) when asking a question. Even if it is wrong/not working, it will help the one providing an answer, and others looking for answers.
In general terms, I found it somewhat helpful to read through the jquery.inputmask.xxx.extensions.js files, where xxx = date in this instance. In there you can see how more complex aliases are constructed from more basic ones (by overriding the basic ones), and you can apply the same ideas in constructing a new alias if you don't find a useful one.
Code that should work for your case:
$("#tsfield").inputmask("timestamp", {
mask: "y/1/2 h:s:s",
placeholder: "yyyy/mm/dd hh:mm:ss",
separator: "/",
alias: "datetime",
hourFormat: "24"
});
... which creates a new alias named timestamp, overriding datetime, and applies it to the input with id="tsfield".
If you have more than one input field with the same input mask on your page, I find it is better to create the new alias just once in your $(document).ready(), and then apply it by name to each field (refer to jquery.inputmask.date.extensions.js and documentation for instructions).

Convert date to string in Sencha 2

I want to convert a date to a string, and sees that Sencha 2 has this class for the job. It has a lot of convertion, but I cant find anyone where I can customize how I want the string formatted. I want a date in 'dd-MM-yyyy'.
In java you have the SimpleDateFormat class where you give the pattern you want it formated in as parameter, I would except there was something like this in the Date class. If not, whats the best way to do this in pure javascript (no third part libraries), I know the trivial way (getFullYear(), getMonth() and such), but its error prone.
http://docs.sencha.com/touch/2-0/#!/api/Date-method-toDateString
have a look at http://docs-devel.sencha.com/touch/2-0/#!/api/Ext.Date
it contains a ton of the format options :)
Cheers, Oleg

Reporting Services - handling an empty date?

Hey, I have a report parameter which looks like this: 01.01.2009 00:00:00
Its a date (as string), as you might have guessed :). The problem is, this param can be an empty string as well. So I tried those expressions:
=IIf(IsDate(Parameters!DateTo.Value), CDate(Parameters!DateTo.Value), "")
=IIf(Len(Parameters!DateTo.Value) > 0, CDate(Parameters!DateTo.Value), "")
Both dont work and the value for the textfield where I print the expressions result is always #Error. As soon as I remove the CDate stuff, it works, but I have to use it. IS there another way to achieve that? What I want is to display nothing if its not a date or the date (format dd.mm.yyyy) if its a date.
Ideas?
Thanks :)
All arguments to the IIf are evaluated, which results in your error, since the CDate will fail for an empty string.
You can get around this by just writting a function along these lines, using a standard if statement:
Function FormatDate(ByVal s As String) As String
If (s <> "") Then
Return CDate(s).ToString()
Else
Return ""
End If
End Function
Then call it with: =Code.FormatDate(Parameters!DateTo.Value)
First, fix your database to properly store dates rather than doing these workarounds. You probably have bad data in there as well (Feb 30 2010 for example or my favorite, ASAP). Truly there is no excuse for not fixing this at the database level where it needs to be fixed except if this is vendor provided software that you can't change (I would yell at them though, well notify them really, and ask them to fix their data model or go to a new product designed by someone who knows what they are doing. A vendor who can't use dates properly is likely to have software that is very poor all around).
In the query that you use to select the infomation, have you considered just converting all non-dates to null?

iRegex for date in user entered textfield

I have an input box and the user can write his DOB(mm/dd/yyyy) into the box.
Before I save the data I like to test for valid input. I am using Regexlite.h and Regexlite.m.I have the regular expression too. I want to compare the regex to the user entered value in text box.But am not knowing how to do it.
Any idea how to test for a valid date? (in .NET I use a simple regex but for the iPhone sdk I am a bit helpless) - but somebody must have been done this before.
Here is a regex you can use to parse it if your looking for something else just leave me a comment
^\d{2}/\d{2}/\d{4}$
I think that you should do more validation than that---you don't want anything happening on 30 February nor allow a birth-year of 1001 and 3001 (time-travellers and Methusaleh's Children can go hang).
Perhaps someone cleverer than I could do this all with regular expressions, but I'd suggest just looking at the string and using some logic.
Why are you not using UIDatePicker to prevent user to enter your own not valid date.