clockpunch 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +5 -0
- data/README.md +4 -1
- data/app/assets/javascripts/clockpunch.js +13 -2
- data/lib/clockpunch/version.rb +1 -1
- metadata +1 -1
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -76,7 +76,7 @@ This library comprises the following pieces:
|
|
76
76
|
|
77
77
|
### Formats
|
78
78
|
|
79
|
-
|
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.
|
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);
|
data/lib/clockpunch/version.rb
CHANGED