Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for AM/PM in @done tags #13

Merged
merged 4 commits into from
Aug 1, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# CHANGELOG

## v1.4.2, 1.8.2020
- [Change] allow @done(date) to be tided up when time has AM/PM suffix (issue 17)

## v1.4.1, 1.8.2020
- [New] add new --noarchive option (issue 16)
- [New] add new --keepscheduled option (issue 14,15)

## v1.4.0, 26.7.2020
- [Change] Script now called `npTools`
- [Change] Significant improvements to documentation

10 changes: 5 additions & 5 deletions npTools.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/ruby
#-------------------------------------------------------------------------------
# NotePlan Tools script
# by Jonathan Clark, v1.4.0, 25.7.2020
# by Jonathan Clark, v1.4.2, 1.8.2020
#-------------------------------------------------------------------------------
# See README.md file for details, how to run and configure it.
# Repository: https://github.com/jgclark/NotePlan-tools/
#-------------------------------------------------------------------------------
VERSION = '1.4.0'.freeze
VERSION = '1.4.2'.freeze

require 'date'
require 'time'
Expand Down Expand Up @@ -522,10 +522,10 @@ def process_repeats
completed_date = ''
# find lines with date-time to shorten, and capture date part of it
# i.e. @done(YYYY-MM-DD HH:MM)
if line =~ /@done\(\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}\)/
if line =~ /@done\(\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}(?:.(?:AM|PM))?\)/
# get completed date
line.scan(/\((\d{4}\-\d{2}\-\d{2}) \d{2}:\d{2}\)/) { |m| completed_date = m.join }
updated_line = line.gsub(/\(\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}\)/, "(#{completed_date})")
line.scan(/\((\d{4}\-\d{2}\-\d{2}) \d{2}:\d{2}(?:.(?:AM|PM))?\)/) { |m| completed_date = m.join }
updated_line = line.gsub(/\(\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}(?:.(?:AM|PM))?\)/, "(#{completed_date})")
@lines[n] = updated_line
cleaned += 1
@is_updated = true
Expand Down