clockpunch 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Clockpunch Changelog
2
2
 
3
+ ## Version 0.1.6 (July 12, 2013)
4
+
5
+ * New h?m format
6
+ * Ability to set default format across the board
7
+
3
8
  ## Version 0.1.5 (July 12, 2013)
4
9
 
5
10
  * Don't apply timeinput multiple times
data/README.md CHANGED
@@ -76,7 +76,7 @@ This library comprises the following pieces:
76
76
 
77
77
  ### Formats
78
78
 
79
- There are three built-in formats:
79
+ #### Built-in formats:
80
80
 
81
81
  * default: "H:MM"
82
82
  * Zero-padded minutes
@@ -84,6 +84,9 @@ There are three built-in formats:
84
84
  * Zero-padded minutes
85
85
  * minutes: MMm
86
86
  * Not zero-padded. Always show total minutes. E.g. 90 minutes stays "90m"
87
+ * h?m
88
+ * If more than an hour it's the same as 'hm'
89
+ * Does not zero-pad minutes if less than an hour
87
90
 
88
91
  To use one of the other formats, just pass it in the constructor, e.g. `new TimeParser('hm')`
89
92
 
@@ -1,7 +1,7 @@
1
1
  // Generated by CoffeeScript 1.4.0
2
2
 
3
3
  /*
4
- Clockpunch 0.1.5
4
+ Clockpunch 0.1.6
5
5
  https://github.com/tablexi/clockpunch
6
6
  */
7
7
 
@@ -127,6 +127,10 @@ https://github.com/tablexi/clockpunch
127
127
  */
128
128
 
129
129
 
130
+ TimeParser.set_default_format = function(string) {
131
+ return this.default_format = string;
132
+ };
133
+
130
134
  TimeParser.to_minutes = function(string) {
131
135
  var parser;
132
136
  parser = new TimeParser();
@@ -244,6 +248,13 @@ https://github.com/tablexi/clockpunch
244
248
  hm: function(hours, minutes) {
245
249
  return this.default_string_format('{HOURS}h{MINUTES}m', hours, minutes);
246
250
  },
251
+ "h?m": function(hours, minutes) {
252
+ if (hours > 0) {
253
+ return formats['hm'].call(this, hours, minutes);
254
+ } else {
255
+ return "" + minutes + "m";
256
+ }
257
+ },
247
258
  minutes: function(hours, minutes) {
248
259
  var total_minutes;
249
260
  total_minutes = hours * 60 + minutes;
@@ -251,7 +262,7 @@ https://github.com/tablexi/clockpunch
251
262
  }
252
263
  };
253
264
  if (format == null) {
254
- return formats['default'];
265
+ return formats[TimeParser.default_format || 'default'];
255
266
  }
256
267
  return formats[format] || function(hours, minutes) {
257
268
  return this.default_string_format(format, hours, minutes);
@@ -1,3 +1,3 @@
1
1
  module Clockpunch
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clockpunch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: