Skip to content

Commit d126e1f

Browse files
committed
switch to gif preview
1 parent 564adb0 commit d126e1f

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Quickly create Google Calendar events from plain text.
44

5-
![preview.jpg](https://raw.githubusercontent.com/mtimkovich/rip_quick_add/main/preview.jpg)
5+
![preview.gif](https://raw.githubusercontent.com/mtimkovich/rip_quick_add/main/preview.gif)
66

77
[Quick Add][article] was a Google Calendar feature that existed from 2012–[2017][rip] that enabled creating calendar events from natural language text input. I loved it and they deprecated it from me ☹️. This is my attempt to carry on its legacy. It uses the [Sherlock][sherlock] library to extract time data from text.
88

preview.gif

1.04 MB
Loading

preview.jpg

-117 KB
Binary file not shown.

rip_quick_add.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import Sherlock from 'sherlockjs';
22
import moment from 'moment';
33

4-
function dateRange(start, end, isAllDay) {
4+
function dateRange(start, end, isAllDay, utc=false) {
55
let formatString = 'YYYYMMDD[T]HHmmss';
66

77
if (isAllDay) {
88
formatString = 'YYYYMMDD';
9+
} else if (utc) {
10+
formatString = 'YYYYMMDD[T]HHmmss[Z]';
911
}
1012

1113
return [start, end].map(t => t.format(formatString)).join('/');
@@ -16,6 +18,12 @@ function parse(text) {
1618
throw new Error('invalid input text');
1719
}
1820

21+
let utc = false;
22+
23+
if (/\bnow\b/.test(text)) {
24+
utc = true;
25+
}
26+
1927
const { eventTitle, startDate, endDate, isAllDay } = Sherlock.parse(text);
2028
const start = moment(startDate);
2129
let end = moment(endDate);
@@ -36,7 +44,7 @@ function parse(text) {
3644
end.add(1, 'days');
3745
}
3846

39-
const dates = dateRange(start, end, isAllDay);
47+
const dates = dateRange(start, end, isAllDay, utc);
4048
return { text: eventTitle, dates }
4149
}
4250

0 commit comments

Comments
 (0)