[PATCH] [Wok] Added util method for formatting timestamp as per locale.

From: Pooja Kulkarni <pkulkark@linux.vnet.ibm.com> Signed-off-by: Pooja Kulkarni <pkulkark@linux.vnet.ibm.com> --- ui/js/src/wok.utils.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/js/src/wok.utils.js b/ui/js/src/wok.utils.js index dcec823..121a51f 100644 --- a/ui/js/src/wok.utils.js +++ b/ui/js/src/wok.utils.js @@ -258,6 +258,13 @@ wok.numberLocaleConverter = function numberConverter(number, locale){ return number; } +wok.timestampConverter = function timestampconverter(timestamp, locale){ + var dte = new Date(timestamp) + var options = { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', + minute: 'numeric', second: 'numeric', timeZoneName: 'short'}; + return dte.toLocaleString(locale, options); +} + wok.localeConverters = { "date-locale-converter": { to: function(date){ -- 2.1.0

On 08/03/2016 03:35 AM, pkulkark@linux.vnet.ibm.com wrote:
From: Pooja Kulkarni <pkulkark@linux.vnet.ibm.com>
Signed-off-by: Pooja Kulkarni <pkulkark@linux.vnet.ibm.com> --- ui/js/src/wok.utils.js | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/ui/js/src/wok.utils.js b/ui/js/src/wok.utils.js index dcec823..121a51f 100644 --- a/ui/js/src/wok.utils.js +++ b/ui/js/src/wok.utils.js @@ -258,6 +258,13 @@ wok.numberLocaleConverter = function numberConverter(number, locale){ return number; }
+wok.timestampConverter = function timestampconverter(timestamp, locale){ + var dte = new Date(timestamp) + var options = { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', + minute: 'numeric', second: 'numeric', timeZoneName: 'short'};
Any specific reason to set month as 'long' and everything else as 'numeric'? According to Moziila docs month can be set as 'numeric' too: https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Obj... month The representation of the month. Possible values are "numeric", "2-digit", "narrow", "short", "long".
+ return dte.toLocaleString(locale, options); +} + wok.localeConverters = { "date-locale-converter": { to: function(date){

I seem to have forgotten to respond to this! Apologies for the late response Please find my comments inline. On 08/03/2016 07:02 PM, Daniel Henrique Barboza wrote:
On 08/03/2016 03:35 AM, pkulkark@linux.vnet.ibm.com wrote:
From: Pooja Kulkarni <pkulkark@linux.vnet.ibm.com>
Signed-off-by: Pooja Kulkarni <pkulkark@linux.vnet.ibm.com> --- ui/js/src/wok.utils.js | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/ui/js/src/wok.utils.js b/ui/js/src/wok.utils.js index dcec823..121a51f 100644 --- a/ui/js/src/wok.utils.js +++ b/ui/js/src/wok.utils.js @@ -258,6 +258,13 @@ wok.numberLocaleConverter = function numberConverter(number, locale){ return number; } +wok.timestampConverter = function timestampconverter(timestamp, locale){ + var dte = new Date(timestamp) + var options = { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', + minute: 'numeric', second: 'numeric', timeZoneName: 'short'};
Any specific reason to set month as 'long' and everything else as 'numeric'? According to Moziila docs month can be set as 'numeric' too:
https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Obj...
month The representation of the month. Possible values are "numeric", "2-digit", "narrow", "short", "long".
This format was chosen as per the globalization implementation guidelines https://w3-connections.ibm.com/wikis/home?lang=en-us#!/wiki/GIG/page/GIG042%... ('Format of time stamps' section)
+ return dte.toLocaleString(locale, options); +} + wok.localeConverters = { "date-locale-converter": { to: function(date){
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
participants (3)
-
Daniel Henrique Barboza
-
pkulkark@linux.vnet.ibm.com
-
Pooja Kulkarni