This repository has been archived by the owner on Oct 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
191 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Changelog | ||
|
||
|
||
## v1.1.0 (2017-02-23) | ||
|
||
### Changes | ||
|
||
- Replace npm package `date-util` with [Sugarjs](https://sugarjs.com/) (#1) | ||
- Refactor plugin | ||
|
||
|
||
## v1.0.0 (2017-02-15) | ||
|
||
- First release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
{ | ||
"name": "zazu-utime", | ||
"version": "1.0.0", | ||
"description": "Convert unix timestamps to human readable dates and vice versa.", | ||
"version": "1.1.0", | ||
"description": "Convert unix timestamps to human-readable dates and vice versa.", | ||
"keywords": [ | ||
"zazu", | ||
"timestamp", | ||
"date" | ||
], | ||
"author": "Puyt", | ||
"license": "MIT", | ||
"dependencies": { | ||
"date-util": "^1.2.1" | ||
} | ||
"license": "MIT" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// load package date-util | ||
require('../libs/sugar-date') | ||
|
||
module.exports = (pluginContext) => { | ||
return { | ||
respondsTo: (query) => { | ||
return true | ||
}, | ||
search: (query = '', env = {}) => { | ||
// check if timestamp given | ||
let isTimestamp = !isNaN(parseFloat(query)) && isFinite(query); | ||
|
||
// default settings | ||
let outputFormat = env['outputFormat'] || '{full}'; | ||
let timestampUnit = 'seconds'; | ||
|
||
// override timestamp unit | ||
if (env['timestampUnit'] && env['timestampUnit'] == 'milliseconds') { | ||
timestampUnit = 'milliseconds'; | ||
} | ||
|
||
// check if string or timestamp is given | ||
if (!isTimestamp) { | ||
// handle timestamp unit | ||
if (timestampUnit == 'seconds') { | ||
// timestamp in seconds | ||
outputFormat = '{X}'; | ||
} else { | ||
// timestamp in milliseconds | ||
outputFormat = '{x}'; | ||
} | ||
} else { | ||
// parse query | ||
query = parseFloat(query); | ||
|
||
// convert given timestamp in seconds to milliseconds | ||
if (timestampUnit == 'seconds') { | ||
query *= 1000; | ||
} | ||
} | ||
|
||
// create Sugar Date | ||
var sugarDate = Sugar.Date.create(query); | ||
|
||
// check if valid date | ||
if (!Sugar.Date.isValid(sugarDate)) { | ||
return Promise.reject(); | ||
} | ||
|
||
// set result value | ||
const value = Sugar.Date.format(sugarDate, outputFormat); | ||
|
||
// set result subtitle | ||
const subtitle = `Select to copy ` + (isTimestamp ? `the formatted date` : `the timestamp in ${timestampUnit}`) + `.`; | ||
|
||
// return results | ||
return new Promise((resolve, reject) => { | ||
resolve([ | ||
{ | ||
icon: 'fa-clock-o', | ||
title: value, | ||
subtitle: subtitle, | ||
value: value, | ||
} | ||
]) | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters