Skip to content

Commit ae0097c

Browse files
committed
docs: update README with flexible date input documentation
- Add 'Why You Might Want to Use This Plugin' section explaining the philosophy of balancing clean code with user-friendly APIs - Document flexible date input support for getEvents() method - Update Dataview and Templater examples to show moment objects, Date objects, and string dates are all supported - Address the specific Templater use case that was reported where users expected moment objects to work directly
1 parent a2d114e commit ae0097c

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

README.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ This is designed to work with the Daily Note or [Periodic Notes](https://github
88

99
I highly recommend pairing this with the [Day Planner](https://github.com/ivan-lednev/obsidian-day-planner) plugin: the output format is tuned to support it and you'll get support for seeing the day and week planners.
1010

11+
## Why You Might Want to Use This Plugin
12+
13+
There are many calendar integration plugins available for Obsidian, some with more features and bells and whistles. This plugin focuses on a different philosophy: **clean, maintainable code that adapts to user expectations rather than forcing users to adapt to the plugin**.
14+
15+
Key advantages of this approach include:
16+
17+
- **User-Friendly API**: The `getEvents()` method accepts date strings, moment objects, or Date objects - whatever is most natural for your use case
18+
- **Performance Through Simplicity**: Support for vdir (local calendar cache) enables lightning-fast workflows by treating your local calendar files as a cache
19+
- **Power User Friendly**: Designed for customization and automation through Templater and Dataview rather than trying to be everything to everyone
20+
- **Focused Feature Set**: Does one thing well - importing calendar events into notes - rather than trying to be a full calendar management system
21+
- **Predictable Behavior**: Clean, testable code that behaves consistently across different environments
22+
23+
If you value simplicity, performance, and the ability to customize your calendar integration exactly how you want it, this plugin might be a good fit for your workflow.
24+
1125
## Installation
1226

1327
This plugin is in the community plugin browser in Obsidian. Search for ICS and you can install it from there.
@@ -39,10 +53,22 @@ For customizations not available to the formatting, use Dataview or Templater (s
3953

4054
### Data view usage
4155

42-
You can also use a [Dataview](https://blacksmithgu.github.io/obsidian-dataview/) to add your events to your journal notes when they get created. For examples, if you use the core Templates plugin you can add the following to add events to your daily note template:
56+
You can also use a [Dataview](https://blacksmithgu.github.io/obsidian-dataview/) to add your events to your journal notes when they get created.
57+
58+
**The `getEvents()` method accepts flexible date inputs**: date strings (like "2025-03-01" or "March 1, 2025"), moment objects, or JavaScript Date objects. This makes it easy to work with whatever date format is most convenient for your use case.
59+
60+
For example, if you use the core Templates plugin you can add the following to add events to your daily note template:
4361

4462
```dataviewjs
63+
// Simple string-based approach
4564
var events = await app.plugins.getPlugin('ics').getEvents(dv.current().file.name);
65+
66+
// Or use a Date object for today's events
67+
var events = await app.plugins.getPlugin('ics').getEvents(new Date());
68+
69+
// Or use moment for date manipulation
70+
var events = await app.plugins.getPlugin('ics').getEvents(moment().add(1, 'day'));
71+
4672
var mdArray = [];
4773
events.forEach((e) => {
4874
mdArray.push(`${e.time} ${e.summary} ${e.location}: ${e.description}`.trim())
@@ -54,11 +80,24 @@ You can see the available fields in the [Event interface](https://github.com/clo
5480

5581
### Templater
5682

57-
Or you can use [Templater](https://github.com/SilentVoid13/Templater):
83+
You can use [Templater](https://github.com/SilentVoid13/Templater) with flexible date inputs. The `getEvents()` method now accepts moment objects directly, so you don't need to convert them to strings:
84+
85+
```javascript
86+
<%*
87+
// Direct moment object usage (recommended)
88+
var events = await app.plugins.getPlugin('ics').getEvents(moment(tp.file.title,'YYYYMMDD'));
89+
events.sort((a,b) => a.utime - b.utime).forEach((e) => {
90+
tR+=`- [ ] ${e.time} ${e.summary} ${e.location? e.location : ''}\n`
91+
})
92+
%>
93+
```
94+
95+
If you prefer to use string dates or need to handle different date formats, you can also do:
5896

5997
```javascript
6098
<%*
61-
var events = await app.plugins.getPlugin('ics').getEvents(moment(tp.file.title,'YYYY-MM-DD'));
99+
// String format (also works)
100+
var events = await app.plugins.getPlugin('ics').getEvents(moment(tp.file.title,'YYYYMMDD').format('YYYY-MM-DD'));
62101
events.sort((a,b) => a.utime - b.utime).forEach((e) => {
63102
tR+=`- [ ] ${e.time} ${e.summary} ${e.location? e.location : ''}\n`
64103
})

0 commit comments

Comments
 (0)