Orbeon calendar behavior - calendar

when using a calendar (input with a bind to a date), is there a way to control the interpretation of the input ?
For what I've seen:
1-31 will be the nth of the current month
32-99 is n day after the first of the current month
x0y is the yth day of xth month of the current year
Then it's a little random
511950 will give 05/01/2050
but 151950 will give 01/05/2050
From what i gathered, the control tries to interpret some symbols (any symbol, this includes digits) as separators.
So for example, 151950 is 1/1/50 instead of 1/5/1950 and because it's more than 50 years, the '50' is translated as 2050 instead of 1950.
This is pretty confusing for users, specially when they explicitly put the year with 4 digits and not only 2.
So i'm looking for a way to be a lot stricter. For instance only allowing the dd/mm/yyyy format (with explicit separators). The rest would render the value invalid instead of trying to translate it in something it is not.
Is there a way to do that ?
We're using Orbeon 3.8, and our forms are mostly in french, so dd/mm order.

The parsing is done with regular expressions. See the code here. (To be fair: this code is old!)
I suspect that the overflow conditions are simply a product of the JavaScript date object.
The only way to change this behavior as far as I know is to change the JavaScript code.

Related

How to customize keyboard input and format?

I've upgraded from material-ui-pickers 2.x to #material-ui/pickers 3.x (both with #date-io/moment). And now I'm struggling with the keyboard input and format.
With version 2.x I used format="D.M.YYYY". The user was able to type for example 1.1.2000 or 04.08.2000 or 12.12.2000.
But with version 3.x the input only strictly allows 1.1.2000. It's not possible to have 2-digit day or month. Though I changed to format="DD.MM.YYYY", but now it's impossible to input 1-digit day or month without a leading zero. E.g. typing 1.1.2000 results in 11.20.00.
How can I achieve one (or both) of the following behaviors?
User can input whatever he wants, including characters (same behavior as with version 2.x). Or:
Listen for . input and then jump to the next input section. I.e. User types 1.2.2000 and it will set 1 for day, then jump to the month section, because user pressed . key, then set 2 for month, then jump to year section, because user pressed . and then set 2000 for year.
I found a kinda hacky solution for case 1 using refuse and rifmFormatter:
<KeyboardDatePicker
refuse={/[^\d\.]+/gi}
rifmFormatter={value => value.replace(/[^\d\.]+/gi, '')}
format={"D.M.YYYY"}
...
/>
This will only allow digits and dot as input in any order, and removes input masking.
Not the optimal solution, but way better than before.

Pull a Date from a comment

Good Morning All.
I have a comment field from an invoice system. The user goes into the invoice and leaves a comment/note on it. The source system tags each note with a date. However, the month is either a single digit or a double digit based on the date the note was entered same with the day. So the issue I am having is that I want to pull all of the invoice notes that start with a certain time period. So the notes always start like either one of these:
6/7/16 7:51 AM
11/11/16 8:11 PM
Is there a way to pull the date from the beginning of the note say using AM or PM as the starting point and working back to the beginning of the string?
What I can tell is that you might use Regular Expressions to extract the date from the string, but SQL server doesn't support the regular expression!
A work around is to use CLR, here an article that explain how to achieve what you want. Regular Expressions in MS SQL Server 2005/2008
To get some help on how to build the regular expression to match the dates, here another article that might help you : Regular Expression Library
The date regular expression could be ((\d{2})|(\d))\/((\d{2})|(\d))\/((\d{2})) ((\d{2})|(\d)):((\d{2})|(\d)) [AP]M
Hope this will help you

What is the optimized way for queries on partial dates in GAE Text Search?

Need to get entities filtering by month instead of complete date values (E.g. Birthdays) using Google App Engine Text Search. On verifying GAE docs, I think it is not possible to query date fields by month directly.
So in order to filter them by month/date, we consider saving each date sub value like Date(DD), Month(MM) and Year(YYYY) as separate NUMBER field along with complete date field.
I verified locally that we can achieve by saving like this. But is this the correct way of saving dates by splitting each field when we want to query on date sub values?
Is there any known/unknown limit on number of fields per document apart from 10GB size limit in GAE Text Search?
Please suggest me.
Thanks,
Naresh
The only time NUMBER or DATE fields make sense is if you need to query on ranges of values. In other cases they are wasteful.
I can't tell from your question exactly what queries you want to run. Are you looking for a (single) specific day of the month (e.g., January 6 -- of any year)? Or just "anything in June (again, without regard to year)"? Or is it a date range: something like January 20 through February 19? Or July 1 through September 30?
If it's a range then NUMBER values may make sense. But if it's just a single specific month, or a single month and day-of-month combination, then you're better off storing month and day as separate ATOM fields.
Anything that looks like a number, but isn't really going to be searched via a numerical range, or done arithmetic on, isn't really a number, and is probably best stored as an ATOM. For example, phone numbers, zip codes (unless you're terribly clever and wanting to do something like "all zip codes in San Francisco look like 941xx" -- but even then if that's what you want to do, you're probably better off just storing the "941" prefix as an ATOM).

SQL2012 UDF for all DateTime format conversions

I need to create a user defined Function that accepts a date input
and a date format input and results in a properly formatted date.
Ex: UDF('7/22', 'Internation')
OUTPUT: 22/7/2012
I need to implement all types of date formatting, or at least as much as possible. I think there should be at least 40 different types.
I've found solutions online that don't really work.
Does anyone have a function like this or can point me in the right direction. I'm pretty new to sql so writing this from scratch would take me until next week!

What date format is this?

I am trying to query some data out of Home Bank using the data file it produces.
This is a transaction that appears in the file:
<ope date="734309" amount="-14.24" account="4" dst_account="0" paymode="0" flags="1" payee="239" category="2" wording="" info="" tags="" kxfer="0" />
I am interested in the date="734309". I've not seen this format before so don't know how to parse it.
The application is written in C if that is any help.
734309 / 365 = 2011.80548
So I guess it's something like "days since 1 January in the year 1". If you know the actual date that that number should represent, you can reconstruct the precise offset from there.
It's probably the result of the SQL TO_DAYS() function, which represents the number of days since the first day of 1 A.D. (I don't know whether TO_DAYS() is specific to MySQL or if it's a standard SQL function.)

Resources