1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-10-05 17:18:00 +03:00
4 Manipulating dates with Chronic
Alex Leferry 2 edited this page 2018-05-17 20:42:29 +02:00
Chronic

A natural language date and time parser.

Examples

Changing time format

Selection

2018-03-21

Command

|chronic '%A, %d %B %Y'

Result

Wednesday, 21 March 2018

Incrementing / Decrementing dates

Selection

2018-03-21

Command

|chronic tomorrow %F

Result

2018-03-22

Grepping

Examples

Grep things to do over the next 7 days:

grep-period 'To do' '%F' today week

Configuration

define-command grep-period -params 4.. -docstring 'grep-period <pattern> <format> <time-start> <time-end> [argument…]: Grep period' %{ %sh{
  pattern=$1
  format=$2
  start=$3
  end=$4
  shift 4
  factory=day
  format="($pattern.+$format)|($format.+$pattern)"
  regex=$(
    chronic-period "$format" "$start" "$end" "$factory" |
    paste --serial --delimiters '|'
  )
  printf "grep '%s' %s" "$regex" "$@"
}}