You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2019/01/23 07:57:43 UTC

[royale-asjs] branch develop updated: Allow typing and deleting of separators

This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 9b4d75a  Allow typing and deleting of separators
9b4d75a is described below

commit 9b4d75af1cd65607a38c9b8d015b3b7db4726415
Author: Harbs <ha...@in-tools.com>
AuthorDate: Wed Jan 23 09:57:34 2019 +0200

    Allow typing and deleting of separators
---
 .../org/apache/royale/html/accessories/StringDateFormatter.as    | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/Formatters/src/main/royale/org/apache/royale/html/accessories/StringDateFormatter.as b/frameworks/projects/Formatters/src/main/royale/org/apache/royale/html/accessories/StringDateFormatter.as
index 72b6fd5..0aa56fc 100644
--- a/frameworks/projects/Formatters/src/main/royale/org/apache/royale/html/accessories/StringDateFormatter.as
+++ b/frameworks/projects/Formatters/src/main/royale/org/apache/royale/html/accessories/StringDateFormatter.as
@@ -42,6 +42,7 @@ package org.apache.royale.html.accessories
         return super.format(value);
       }
       var str:String = value as String;
+      var lastChar:String = str ? str[str.length-1] : "";
       str = str.replace(/[^0-9]/g,"");
       var result:String = "";
       var tokens:Array = dateFormat.split(_separator);
@@ -76,6 +77,9 @@ package org.apache.royale.html.accessories
             {
               // part is ok. We need to slice the str
               str = str.substr(2);
+              //manually added separator. Add a 0.
+              if(part.length == 1 && lastChar == _separator)
+                part = "0" + part;
             }
             result += part;
             break;
@@ -91,12 +95,15 @@ package org.apache.royale.html.accessories
             {
               // part is ok. We need to slice the str
               str = str.substr(2);
+              //manually added separator. Add a 0.
+              if(part.length == 1 && lastChar == _separator)
+                part = "0" + part;
             }
             result += part;
             break;
         }
         // if there's no more left, str is empty and no separator
-        if (str && i <= length - 2) {
+        if ( (str || lastChar == _separator) && i <= length - 2) {
           result += _separator;
         }
       }