Extjs Form Field: Parse Hours using format like '3d 4h'? - extjs

I would like to have a textfield, representing the amount of time of something, parse a text value like '3d 4h' into hours. The example I provide would be 3 days, 4 hours -- 76 hours.
Before I go off and roll my own text-to-number parser engine, has anyone done something like this before, or does Extj4 provide a way to ease this process?
Thanks!

I haven't seen this in JS.
You might get some inspiration looking at the source code for PHP's strtotime function, which does essentially what you are looking for:
https://github.com/php/php-src/blob/master/ext/date/php_date.c#L1324
Other options:
regex for textual dates? (aka source code for php's strtotime )

Related

react-intl display currency symbol only

Working with react-intl and was looking to display a currency symbol only, after some text like USD$.
From what I have read so far in the documentation guessing FormattedNumber requires a default value.
Just wondering is it possible to display a currency symbol without a number value? such as $ (currently it returns NaN, due to missing number value)
Wondering has anyone run into this kind of issue previously?
Guessing there must be a simple solution.
In the meantime will keep looking for alternative solutions.
Any thought greatly appreciated.
Wasn't able to find a solution with react-intl.
So created simple helper to do the job.
Works ok. :)

How to properly format wordpress post date in ionic angularjs

I am working on a news blog mobile app using wordpress WP-API, everything else is working ok, but am having problem formatting the wordpress post date
this {{post.date}} gives me something like2016-08-07T15:45:26
How ever I want to format the date to have something like dd-mm-year, then in another one I get the time, instead of 15:45:26, I want to get something like 3:45 pm.
If possible, I will also like a filter that returns the date 2016-08-07T15:45:26 to something like 24 hours ago, 2 days ago, 1 week ago etc
Thanks
Had the same problem too. You may want to check this
:https://weblog.west-wind.com/posts/2014/jan/06/javascript-json-date-parsing-and-real-dates
You could use a date manipulation library to convert the datetime provided by WordPress to the desired format. You may want to check out Moment.js.

Change format of the "date" variable when writing snippets in KDevelop

I am writing a simple snippet in KDevelop 4 to print the date of today, taking advantage of the Snippets feature and of the variable %{date}. The default format, however, is apparently MM/DD/YYYY, and I'd like to change it into YYYY-MM-DD. I have browsed over the Settings of both the Editor and the whole KDevelop, without luck. Can anyone point me to the relevant settings, if any exists?
I am using version 4, but I guess that's close to irrelevant (or is it?).
Found the answer in the KDE Help Center: %{date} is a Kate template macro (Kate is the editor used by KDevelop). Its expansion depends on the system locale, and there is no indication about a way to change the locale. By using other macros, however, I can obtain the desired result:
%{year}-%{month}-%{day}
For more complex cases, I suspect I'd need some more digging into the Kate Template Format, but the information so far satisfies my immediate need.

Dojo Calendar is only showing numbers instead of month names

I currently have a problem with Dojo's calendar. It doesn't seem to be showing the name of the month when the locale is switched to zh-tw.
Instead of getting:
一月
二月
三月
。。。
we get
1
2
3
...
We don't have this problem when Dojo the locale is set to en. This is somewhat related to https://bugs.dojotoolkit.org/ticket/10490.
Anyone have a clue as to how to fix this? :)
Thanks!
That's because they implemented it that way. You can look at the source code and see that the months are numbered. You can even compare it to the English version.
As far as I know there is no way to extend or override this, so you will have to extend the dijit.Calendar._MonthDropDown yourself and hardcode it (not that this is a best practice).

regex for time 24 hour format in extjs 3

I am little weak in regular expression. Can anybody help me in finding regular expression for time (in 24 hour format) in extjs
Thank you.
Don't reinvent the wheel if you don't have to. The fine folks at Sencha went through a lot of trouble so that developers like us don't have to mess with this sort of thing.
// returns null if parse failed, or Date object is successful
var mydate = Ext.Date.parse(inputString, "G:i");
For more information, check the API docs for Ext.Date
This might be what you are looking for:
'/^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/'
Not sure if it works on extis, if not you can always translate it back to the syntax uses in extis.
Try out
^(20|21|22|23|[01]\d|\d)(([:][0-5]\d){1,2})$
or you can use
([01]?[0-9]|2[0-3]):[0-5][0-9]
For more info visit tutorial

Resources