clockpunch 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,10 @@
1
1
  # Clockpunch Changelog
2
2
 
3
+ ## Version 0.1.7 (August 1, 2013)
4
+
5
+ * Specify format via data-format attribute
6
+ * Long (e.g. "1 hour 30 minutes") output format
7
+
3
8
  ## Version 0.1.6 (July 12, 2013)
4
9
 
5
10
  * New h?m format
data/README.md CHANGED
@@ -87,6 +87,9 @@ This library comprises the following pieces:
87
87
  * h?m
88
88
  * If more than an hour it's the same as 'hm'
89
89
  * Does not zero-pad minutes if less than an hour
90
+ * long: "H hour(s), M minute(s)"
91
+ * Should only be used in spans (since it is not currently parsable)
92
+ * H will not be shown if zero
90
93
 
91
94
  To use one of the other formats, just pass it in the constructor, e.g. `new TimeParser('hm')`
92
95
 
@@ -1,7 +1,7 @@
1
1
  // Generated by CoffeeScript 1.4.0
2
2
 
3
3
  /*
4
- Clockpunch 0.1.6
4
+ Clockpunch 0.1.7
5
5
  https://github.com/tablexi/clockpunch
6
6
  */
7
7
 
@@ -17,7 +17,9 @@ https://github.com/tablexi/clockpunch
17
17
  options = {};
18
18
  }
19
19
  return this.each(function(input_field) {
20
- return new TimeParsingInput(this, options['format']);
20
+ var format;
21
+ format = options['format'] || $(this).data('format');
22
+ return new TimeParsingInput(this, format);
21
23
  });
22
24
  }
23
25
  });
@@ -259,7 +261,8 @@ https://github.com/tablexi/clockpunch
259
261
  var total_minutes;
260
262
  total_minutes = hours * 60 + minutes;
261
263
  return total_minutes.toString();
262
- }
264
+ },
265
+ long: this.long_format
263
266
  };
264
267
  if (format == null) {
265
268
  return formats[TimeParser.default_format || 'default'];
@@ -273,6 +276,26 @@ https://github.com/tablexi/clockpunch
273
276
  return format_string.replace('{HOURS}', hours).replace('{MINUTES}', TimeParser.pad(minutes.toString()));
274
277
  };
275
278
 
279
+ TimeParser.prototype.long_format = function(hours, minutes) {
280
+ var output;
281
+ output = [];
282
+ if (hours > 0) {
283
+ output.push("" + hours + " " + (this.pluralize(hours, 'hour')));
284
+ }
285
+ if (minutes > 0 || (minutes === 0 && hours === 0)) {
286
+ output.push("" + minutes + " " + (this.pluralize(minutes, 'minute')));
287
+ }
288
+ return output.join(" ");
289
+ };
290
+
291
+ TimeParser.prototype.pluralize = function(count, string) {
292
+ if (count === 1) {
293
+ return string;
294
+ } else {
295
+ return "" + string + "s";
296
+ }
297
+ };
298
+
276
299
  return TimeParser;
277
300
 
278
301
  })();
@@ -1,3 +1,3 @@
1
1
  module Clockpunch
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
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.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-12 00:00:00.000000000 Z
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sass