Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Apply '-' behaviour to blank padded format directives. #292

Merged
merged 1 commit into from

2 participants

Sébastien Le Callonnec Charles Oliver Nutter
Sébastien Le Callonnec
Collaborator

This commit addresses jruby issue #289. The expected behaviour is documented in this rubyspec pull request: rubyspec/rubyspec#153

Sébastien Le Callonnec tychobrailleur Apply '-' behaviour to blank padded format directives.
This commit addresses jruby issue #289.  The expected behaviour is documented in this rubyspec pull request: rubyspec/rubyspec#153
6f86d35
Charles Oliver Nutter headius merged commit 5391e26 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 7, 2012
  1. Sébastien Le Callonnec

    Apply '-' behaviour to blank padded format directives.

    tychobrailleur authored
    This commit addresses jruby issue #289.  The expected behaviour is documented in this rubyspec pull request: rubyspec/rubyspec#153
This page is out of date. Refresh to see the latest.
2  src/org/jruby/util/TimeOutputFormatter.java
View
@@ -121,7 +121,7 @@ public String format(String sequence) {
paddedWith = '0';
break;
case '-':
- sequence = sequence.replaceAll("^[0]", "");
+ sequence = sequence.replaceAll("^[0 ]", "");
break;
}
}
10 test/org/jruby/util/TimeOutputFormatterTest.java
View
@@ -88,4 +88,14 @@ public void testPaddingWithUpperCase() {
TimeOutputFormatter formatter = TimeOutputFormatter.getFormatter("%^5H");
assertEquals(" UP", formatter.format("up"));
}
+
+ public void testFormatNoPaddingForBlankPaddedValues() {
+ TimeOutputFormatter formatter = TimeOutputFormatter.getFormatter("%-3H");
+ assertEquals("up", formatter.format(" up"));
+ }
+
+ public void testFormatNoPaddingForZeroPaddedValues() {
+ TimeOutputFormatter formatter = TimeOutputFormatter.getFormatter("%-3H");
+ assertEquals("up", formatter.format("0up"));
+ }
}
Something went wrong with that request. Please try again.