Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/v1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Depondt committed Feb 22, 2017
2 parents 850296a + 5a436ed commit 907011a
Show file tree
Hide file tree
Showing 18 changed files with 191 additions and 144 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
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
46 changes: 28 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
## Zazu-utime

Plugin for [Zazu](http://zazuapp.org/) inspired by this [Chrome extension](https://chrome.google.com/webstore/detail/kpcibgnngaaabebmcabmkocdokepdaki).
A simple timestamp plugin for [Zazu](http://zazuapp.org/), inspired by this [Chrome extension](https://chrome.google.com/webstore/detail/kpcibgnngaaabebmcabmkocdokepdaki).

## Keywords
See [date-util](https://www.npmjs.com/package/date-util) for examples.

Added a few custom missing keywords in date-util:
- today
- now
- tomorrow
- yesterday
## Usage

Open Zazu and type a timestamp or human-readable date, the plugin will try and translate most of it.

Examples:
- `now`
- `today`
- `1487718000`
- `the end of next week`

For more examples see https://sugarjs.com/dates/#/Parsing


## Installing
Expand All @@ -26,7 +30,7 @@ Add `puyt/zazu-utime` inside of `plugins` block of your `~/.zazurc.json` file.

### Variables
- `timestampUnit`: seconds or milliseconds
- `outputFormat`: see npm package [date-util](https://www.npmjs.com/package/date-util#date-format)
- `outputFormat`: see https://sugarjs.com/dates/#/Formatting for all possible options

~~~ json
{
Expand All @@ -35,7 +39,7 @@ Add `puyt/zazu-utime` inside of `plugins` block of your `~/.zazurc.json` file.
"name": "puyt/zazu-utime",
"variables": {
"timestampUnit": "milliseconds",
"timestampUnit": "yyyy/mm/dd HH:MM:ss"
"timestampUnit": "{yyyy}/{MM}/{dd} {HH}:{mm}:{s}"
}
}
]
Expand All @@ -44,13 +48,19 @@ Add `puyt/zazu-utime` inside of `plugins` block of your `~/.zazurc.json` file.


## Screenshots
![now](./assets/screenshot_now1.png)
![now2](./assets/screenshot_now2.png)
![tomorrow](./assets/screenshot_tomorrow1.png)
![tomorrow2](./assets/screenshot_tomorrow2.png)
![friday](./assets/screenshot_friday1.png)
![friday2](./assets/screenshot_friday2.png)
![example1](./assets/example1.png)
![example2](./assets/example2.png)
![example3](./assets/example3.png)
![example4](./assets/example4.png)


## Acknowledgments
Most the plugin it's :muscle: is coming from [Sugarjs](https://sugarjs.com/)


## See also
- [`tinytacoteam/zazu`](http://github.com/tinytacoteam/zazu)

## License

## Uses
- [date-util](https://www.npmjs.com/package/date-util)
[MIT](LICENSE.md)
Binary file added assets/example1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/example2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/example3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/example4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/screenshot_friday1.png
Binary file not shown.
Binary file removed assets/screenshot_friday2.png
Binary file not shown.
Binary file removed assets/screenshot_now1.png
Binary file not shown.
Binary file removed assets/screenshot_now2.png
Binary file not shown.
Binary file removed assets/screenshot_tomorrow1.png
Binary file not shown.
Binary file removed assets/screenshot_tomorrow2.png
Binary file not shown.
73 changes: 73 additions & 0 deletions libs/sugar-date.js

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions package.json
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"
}
73 changes: 0 additions & 73 deletions src/string.js

This file was deleted.

35 changes: 0 additions & 35 deletions src/timestamp.js

This file was deleted.

69 changes: 69 additions & 0 deletions src/utime.js
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,
}
])
})
}
}
}
16 changes: 4 additions & 12 deletions zazu.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
{
"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.",
"blocks": {
"input": [
{
"id": "StringToTimestamp",
"id": "utime",
"type": "RootScript",
"script": "src/string.js",
"connections": [
"Copy"
]
},
{
"id": "TimestampToString",
"type": "RootScript",
"script": "src/timestamp.js",
"script": "src/utime.js",
"connections": [
"Copy"
]
Expand Down

0 comments on commit 907011a

Please sign in to comment.