Auto format date with Zend_Form_Element_DateTextBox - zend-form

guys, this is a short to the point question. Is it possible to auto add the "slashes" on a Zend_Form_Element_DateTextBox while the user is typing? For example, et say my format is dd/mm/yyyy . So the user would start typing 12 and the system would automatically add the /after it. So when typing a date you wouldn't have to add them, but simply, for example, typing 12052009 would correctly format it to 12/05/2009

No, its not. And i think this would not be a good thing to add to the dojo functionality.
What if someone wants to type 1/1/2009:
Then you automatically would get 11/20/09. You would have to have to ask the user to use zeros (01/01/2009) in some way ! Would be frustrating !

Related

How to determine Thousands Separator using Format in VBA

I would like to determine the Thousand Separator used while running a VBA Code on a target machine without resolving to calling system built-in functions such as (Separator = Application.ThousandsSeparator).
I am using the following simple code using 'Format':
ThousandSeparator = Mid(Format(1000, "#,#"), 2, 1)
The above seems to work fine, and would like to confirm if this is a safe method of doing it without resorting to system calls.
I would expect the result to be a single char string in the form of , or . or ' or a Space as applicable to the locale on the machine.
Please note that I want to only use a language statement such as Format or similar (no sys calls). Also this relates to Thousands Separator not Decimal Separator. This article Using VBA to detect which decimal sign the computer is using does not help or answer my question. Thanks
Thanks in advance.
The strict answer to whether it is safe to use Format to get the thousands separator is No.
E.g. on Windows, it is possible to enter up to three characters into the Thousands Separator field in the regional settings in the control panel.
Suppose you enter asd and click OK.
If you now call Format(1000, "#,#") it will give you 1a000. That is only the first letter of your thousands separator. You have failed to retrieve it correctly.
Reading the registry:
? CreateObject("WScript.Shell").RegRead("HKCU\Control Panel\International\sThousand")
you get back asd in full.
To be fair, the Excel international properties do not seem to be of much help either. Application.International(xlThousandsSeparator) in this situation will return the separator originally defined in your computer's locale, not the value you've overridden it to.
Having that said, the practical answer is Yes, because it would appear (and if you happen to know for sure, please post an answer here) that there is no culture with multi-char thousand separator (even in China where scary things like 1ε„„2345δΈ‡6789 or 1ε„„2345萬6789 exist, they happen to be represented with just one UTF-16 character), and you probably are happy to ignore the people who decided to play with their locale settings in that fashion.

How to make the currency symbol display after the numbers and add a space between them in PrestaShop 1.7.4.2

Hello!
Since the 1.7 update of PrestaShop you cannot customize the currency any longer. In my theme by default, the currency symbol displays right before the numbers, without any space. But it should be exactly opposite, symbol after the numbers with a space between them. If anyone knew a way around I would be very grateful.
I could explain here, but there are a lot of tutorials in the web, which I think can be more useful, here one to change the symbol: https://zemez.io/prestashop/support/how-to/prestashop-1-7-%D1%81hange-currency-symbol/
If you want to change the position of the symbol, you need
Go to translations/cldr/main--xx-XX--numbers file (where xx-XX is your language, en-EN, de-DE or ru-RU). Open this file with any code editor.
Find something like this "accounting":" and "standard" and move the \u00a0 to the start or end, depending on where you want to place the symbol.
For example I will move the symbol from the start to the end en-US numbers.
Before: "accounting":"\u00a4#,##0.00;(\u00a4#,##0.00)","standard":"\u00a4#,##0.00"
After: "accounting":"#,##0.00\u00a4;(#,##0.00\u00a4)","standard":"#,##0.00\u00a4"
Hpe this help!
If somebody searching for changing currency sign on PS 1.7.6.
Now it is in the table ps_currency_lang
Via admin panel cannot be changed at the momen, only phpmyadmin :(

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

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

Objective-C: How to use both "." and "," as a decimal separator or at least convert one to another on-the-fly

I have an instance of NSTextField, e.g. someTextField, for which I will use the number formatter to limit the input to numbers only.
The problem comes with the localization combined with the specific keyboard layouts used.
I would like to allow both the, say, American and European users to enter their localized decimal separators. As you all know, in the USA that would be . and for the good part of Europe that would be , (and similar with the thousands separator, etc. but let's put that to the side for now).
So I wrote the following task:
[numberFormatter setLocale:[NSLocale currentLocale]]; for the instance of the NSNumberFormatter.
Problems occurs when the user who has , set as a decimal separator AND US keyboard layout switched on (fairly common here in Europe) presses the decimal separator key on the numeric keyboard. With the US keyboard layout on, that would give him the . as the decimal separator but at the same time it'll be ignored in the someTextField because of the localized settings system-wide. So, if you want to type 1/2 using numeric keyboard only, you'll type 0.5 (US keyboard layout) in the text field and it would be read by the system as 0 because it recognizes only , as decimal separator. This is how the program currently is working and I would like to improve it in this regard.
I would like to allow user to type in the . in the someTextField and for the system to recognize it as a decimal separator just like it would ,. This kind of behavior can be seen in Apple's own Calculator application. If you type . on the numeric keyboard it'll appear as , immediately on the screen (for all conditions as described previously).
Question is: is it possible for me to achieve this using an instance of NSNumberFormatter? If not, is it possible to set on-the-fly conversion of the numerical keyboard decimal separator key output to the decimal separator set system-wide? Or perhaps you have some other suggestions?
Thanks.
I don't have a specific answer to your question, but I'd say the right approach is not to muck about with the NSNumberFormatter at all and concentrate on trying to change the characters generated by the keyboard.
The default locale for number formatters is usually the system's default locale as set by the user in the internationalization settings. If you change that behaviour programmatically for UI elements, you are effectively telling the user "I know better than you how you want to input numbers". Arrogance of that sort on the part of the developer never gets them good marks with respect to UI design.
In fact, you could apply the same argument to remapping the dot button on the numeric keypad. How do you know that the user hasn't set US keyboard layout because it allows them to get a dot from that key? Maybe they consider it more important to be able to type the thousands separator from the keypad than the decimal separator. I'm not saying you shouldn't implement your feature, just make sure that the user has control over when it is enabled or disabled.
Anyway, you probably want to override the keyDown event on the control. More info here.
Take a look at the UITextFieldDelegate protocol. It allows your textfield to ask its delegate if it should accept a character which the user just typed. The apropriate method would be textField:shouldChangeCharactersInRange:replacementString. If the character in question is , or . just let the delegate append the properly localized decimal separator "manually" and return NO.
I'm not quite sure if this will work if the text field is set to number mode, maybe the input is being filtered before the delegate method is called - leading to the method not being called if the "wrong" separator has been filtered out previously. If so, you might want to consider leaving the text field in alphanumerical mode and use the delegate method again to filter out anything that is not numbers or separators. However, in this case you should make sure the user is not allowed to type more then one decimal separator - either ignore the surplus ones or remove the first one and accept the new one.

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.