Skip to content

For "Open Journal" command, change date format in file name  #792

@noah-arroyo

Description

@noah-arroyo

I'd like to make it so that when I open a new journal page, the default file name is a date with the format %Y%m%d%H%M%S.

For example, it would read "20250523145500.md" for a file created on May 23 at 2:55:00 PM.

I've been fiddling, and I've almost figured this out. Hoping you can help me get the rest of the way.

I'm on Linux (Ubuntu 24.04). I've put an edited wiki_page.py file in a new folder: ~/.config/sublime-text/Packages/MarkdownEditing/plugins.

I edited Line 13 of that file to apply my desired format:

DEFAULT_DATE_FORMAT = "%Y%m%d%H%M%S"

I also modified ST's key bindings file to include the following, in order to bind the "open journal" command to ctrl+alt+n:

	{ "keys": ["ctrl+alt+n"], "command": "mde_open_journal", "context":
		/*wiki reference: open a journal page*/
		[
			{ "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true },
			{ "key": "setting.mde.keymap_disable.open_journal", "operator": "not_equal", "operand": false }
		]
	}

Now, when I press ctrl+alt+n, ST creates and opens a .md file with the correct date/time format. But it only captures the date, not the time. I.e., rather than being "20250523145500.md" — the desired outcome — it's "20250523000000.md".

I'm guessing that I need to modify something within lines 57-64? Here's that code, just for easy reference:

class MdeOpenJournalCommand(MdeTextCommand):
    def run(self, edit):
        today = date.today()
        date_format = self.view.settings().get("mde.journal.dateformat", DEFAULT_DATE_FORMAT)
        name = today.strftime(date_format)

        wiki_page = WikiPage(self.view)
        wiki_page.select_page(name)

Thanks so much in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions