Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
evanwalsh committed May 14, 2020
1 parent 0380cda commit fe11459
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog

## v1.1.0

- **BREAKING**: `toDecimal` and `toHHMM` will now _always_ return a `string` type, regardless of input.
- **BREAKING**: `toDecimal` will now return a blank string when passed an invalid value, just like `toHHMM` does.
- The build system now uses TypeScript 3.9.2 and targets ES2020.

## v1.0.0

Initial release
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ declare const _default: {
* @param {number|string} input? Timestamp to convert
* @returns {string} A timestamp in decimal format (rounded/padded to 2 decimals places)
*/
toDecimal(input?: string | number | undefined): string | number | undefined;
toDecimal(input?: string | number | undefined): string;
/** Convert timestamp to hh:mm format
* @param {number|string} input? Timestamp to convert
* @returns {string} A timestamp in hh:mm format
*/
toHHMM(input?: string | number | undefined): string | number | undefined;
toHHMM(input?: string | number | undefined): string;
};
export default _default;
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ exports.default = {
*/
toDecimal(input) {
if (!input && input !== 0) {
return input;
return '';
}
if (typeof (input) === 'number') {
return input.toFixed(2);
}
const hours = evalInput(input) / 60;
return (isNaN(hours) ? '0.00' : hours.toFixed(2).toString());
return (isNaN(hours) ? '' : hours.toFixed(2).toString());
},
/** Convert timestamp to hh:mm format
* @param {number|string} input? Timestamp to convert
* @returns {string} A timestamp in hh:mm format
*/
toHHMM(input) {
if (!input && input !== 0) {
return input;
return '';
}
let total = evalInput(input);
if (isNaN(total)) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hour-parser",
"version": "1.0.0",
"version": "1.1.0",
"description": "Parse timestamp input and get nice output",
"main": "index.js",
"types": "index.d.ts",
Expand Down

0 comments on commit fe11459

Please sign in to comment.