All Projects → argenos → nldates-obsidian

argenos / nldates-obsidian

Licence: MIT license
Work with dates in natural language in Obsidian

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to nldates-obsidian

obsidian-plugin-template
Template for Obsidian.md Plugins
Stars: ✭ 32 (-87.83%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-icon-swapper
Allows swapping out Obsidian's icons
Stars: ✭ 30 (-88.59%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian42-jump-to-date
Jump to a date via a convenient popup form. This plugin is a part of the Obsidian42 family of Obsidian plugins.
Stars: ✭ 28 (-89.35%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-todoist-plugin
Materialize Todoist tasks in Obsidian notes
Stars: ✭ 521 (+98.1%)
Mutual labels:  obsidian-plugin, obsidian-md
longform
A plugin for Obsidian that helps you write and edit novels, screenplays, and other long projects.
Stars: ✭ 311 (+18.25%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-budget-wysiwyg
Obsidian plugin that automatically switches between preview and source mode.
Stars: ✭ 25 (-90.49%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-pandoc
Pandoc document export plugin for Obsidian (https://obsidian.md)
Stars: ✭ 393 (+49.43%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-gist
📒 Gist View for Obsidian(https://obsidian.md)
Stars: ✭ 23 (-91.25%)
Mutual labels:  obsidian-plugin, obsidian-md
statusbar-pomo-obsidian
A status bar pomodoro timer plugin for Obsidian.
Stars: ✭ 51 (-80.61%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-link-archive
Link Archive plugin for Obsidian
Stars: ✭ 94 (-64.26%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-tracker
A plugin tracks occurrences and numbers in your notes
Stars: ✭ 661 (+151.33%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-hypothesis-plugin
An Obsidian.md plugin that syncs highlights from Hypothesis.
Stars: ✭ 164 (-37.64%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-better-pdf-plugin
Goal of this Plugin in to implement a native PDF handling workflow in Obsidian
Stars: ✭ 120 (-54.37%)
Mutual labels:  obsidian-plugin, obsidian-md
oz-image-in-editor-obsidian
This Obsidian plugin to view Images, Transclusions, iFrames and PDF Files within the Editor without a necessity to switch to Preview.
Stars: ✭ 243 (-7.6%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-rollover-daily-todos
An obsidian plugin that rolls over todo items from the previous daily note
Stars: ✭ 52 (-80.23%)
Mutual labels:  obsidian-plugin, obsidian-md
oz-clear-unused-images-obsidian
Obsidian plugin to clear the images that are not used in note files anymore
Stars: ✭ 92 (-65.02%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-tweet-to-markdown
An Obsidian.md plugin to save tweets as Markdown files.
Stars: ✭ 35 (-86.69%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-emoji-toolbar
No description or website provided.
Stars: ✭ 35 (-86.69%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-fullscreen-plugin
No description or website provided.
Stars: ✭ 30 (-88.59%)
Mutual labels:  obsidian-plugin, obsidian-md
obsidian-simple-embeds
A plugin for Obsidian that automatically turns links into embeds.
Stars: ✭ 131 (-50.19%)
Mutual labels:  obsidian-plugin, obsidian-md

Natural Language Dates in Obsidian

Insert timestamps and cross-link your daily notes with the flexibility of natural language. NLDates provides a suite of tools that makes working with dates and times within Obsidian frictionless.

Features

If a date is not recognized, the link won't be created.

Date Autosuggest

autosuggest-demo

Expand dates using natural language inline within the editor view.

Typing @today Enter will automatically be expanded to the current date. Press Shift at the same time to keep the input text as an alias (e.g. @today[[202112-27|today]]).

Configuration

Setting Description Default
Enable/Disable A global toggle to enable or disable the autosuggest Enabled
Trigger phrase Character(s) required to open the autosuggest @
Insert as link? Dates will be inserted as wikilinks (i.e. [[<date>]]) Yes

nldates URI Action

It's now possible to use the Obsidian URI to open daily notes using natural language by using the nldates action obsidian://nldates?day=<date here>. Don't forget to encode space characters appropriately.

obsidian://nldates Parameter Description
day natural language date string
newPane open note in new pane, default is yes

Commands and Hotkeys

nldates adds a few commands to work with dates in natural language. You can add custom hotkeys for them by going to Settings > Hotkeys and filtering by Natural Language Dates (Note that hotkeys are unset by default starting on v0.4.1).

Natural Language Dates: Date Picker

date-picker

Opens the date picker menu

Other Commands

Setting Description Default
Insert current date Inserts the current date, using the format specified in the settings menu YYYY-MM-DD
Insert current time Inserts the current time, using the format specified in the settings menu HH:mm
Insert current date and time Inserts the current date, using the format specified in the settings menu YYYY-MM-DD HH:mm
Parse natural language date Parses the selected text as a natural language date. Replaces selected text with an obsidian link to the parsed date in the format specified in the settings menu.

For single-word dates (e.g. today, tomorrow, friday, etc.), it's possible to use the command without selecting the word first. It's also possible to use dates like Nov9, 25Dec to use this trick.
[[YYYY-MM-DD]]
Parse natural language time Parses the selected text as a natural language time. Replaces selected text with the parsed time stamp in the format specified in the settings menu. You can try with any of the standard times, i.e. now, in 15min, in 1h, 5min ago, etc. HH:mm
Parse natural language date (as link) Parses the selected text as a natural language date. Replaces selected text with a standard markdown link to the parsed date in the format specified in the settings menu [selected text](YYYY-MM-DD)
Parse natural language date (as plain text) Parses the selected text as a natural language date. Replaces selected text with a plain text parsed date in the format specified in the settings menu YYYY-MM-DD

Note: You can of course add hotkeys to each of these commands.

Usage

Examples

The parser supports most date/time formats, including:

  • Today, Tomorrow, Yesterday, Last Friday, etc
  • 17 August 2013 - 19 August 2013
  • This Friday from 13:00 - 16.00
  • 5 days ago
  • 2 weeks from now
  • Sat Aug 17 2013 18:40:39 GMT+0900 (JST)
  • 2014-11-30T08:15:30-05:30

Demo

demo

Note: The parser will replace all the selected text, meaning that in a sentence you should only select the dates to be parsed and not the full sentence.
In the example sentence Do this thing by tomorrow, only the word tomorrow should be selected. Alternatively, keep in mind that you can place your cursor on or next to the word tomorrow, and it will be replaced:

Supported selections

How to install

In Obsidian go to Settings > Third-party plugins > Community Plugins > Browse and search for Natural Language Dates.

Manual installation

Unzip the latest release into your <vault>/.obsidian/plugins/ folder.

About

Powered by the chrono library and some custom parsing.

Custom Parsing

The only behaviours I changed were the following:

Write Date
next week next Monday
next [month] 1st of next month
mid [month] 15th of the month
end of [month] last day of the month

For Developers

NLDates provides an interface for you to parse natural language dates in your plugin. The parsedDate() function is available on the NaturalLanguageDates plugin instance. It has the following signature:

interface NLDResult {
  formattedString: string;
  date: Date;
  moment: Moment;
}

function parseDate(date: string): NLDResult;
  • The formattedString will return the date formatted according to the settings of nldates and without the square brackets.
  • The date object is what is returned by the parseDate method of the custom parser (using the chrono package).
  • The moment object is created with the date object.

Example Usage

const nldatesPlugin = obsidianApp.plugins.getPlugin("nldates-obsidian");
const parsedResult = nldatesPlugin.parseDate("next year");
console.log(parsedResult.moment.format("YYYY")); // This should return 2021

Typical String Formats and Tokens

Input Example Description
YYYY 2014 4 or 2 digit year. Note: Only 4 digit can be parsed on strict mode
YY 14 2 digit year
Y -25 Year with any number of digits and sign
Q 1..4 Quarter of year. Sets month to first month in quarter.
M MM 1..12 Month number
MMM MMMM Jan..December Month name in locale set by moment.locale()
D DD 1..31 Day of month
Do 1st..31st Day of month with ordinal
DDD DDDD 1..365 Day of year
X 1410715640.579 Unix timestamp
x 1410715640579 Unix ms timestamp
gggg 2014 Locale 4 digit week year
gg 14 Locale 2 digit week year
w ww 1..53 Locale week of year
e 0..6 Locale day of week
ddd dddd Mon...Sunday Day name in locale set by moment.locale()
GGGG 2014 ISO 4 digit week year
GG 14 ISO 2 digit week year
W WW 1..53 ISO week of year
E 1..7 ISO day of week

For further information, see: moment.js docs.

Manipulating the moment instance

If you need, you can further manipulate or format the moment object, for example:

const nldatesPlugin = obsidianApp.plugins.getPlugin("nldates-obsidian");
const nextYear = nldatesPlugin.parseDate("next year");

console.log(nextYear.moment.format("YYYY")); // This should return 2021
console.log(nextYear.moment.fromNow()); // "In two months"

const thisEvening = nldatesPlugin.parseDate("today at 21:00");
console.log(thisEvening.moment.add(1, "hour")); // This would change the Moment to 22:00

Note that if you manipulate the parsedResult.moment, the date and formattedString won't be updated. If you don't want to alter the parsedResult.moment, you should clone it. Read more about that on the moment.js docs site.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].