Project

diter

0.0
No commit activity in last 3 years
No release in over 3 years
Date iteration utility.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 5.0
~> 10.0
~> 0.9
 Project Readme

Diter

diter is a date iteration command.

Installation

$ go get github.com/ojima-h/diter

Or download the script:

$ curl -L https://github.com/ojima-h/diter/releases/download/v1.0.0/diter-1.0.0.linux-amd64 > diter
$ chmod +x diter

Usage

Basic usage:

$ diter 2016-01-01 2016-01-03
2016-01-01
2016-01-02
2016-01-03

Run command:

$ diter 2016-01-01 2016-01-03 -- echo date={}
date=2016-01-01
date=2016-01-02
date=2016-01-03

Reverse order:

$ diter 2016-01-03 2016-01-01 -- echo date={}
date=2016-01-03
date=2016-01-02
date=2016-01-01

Date format:

$ diter 2016-01-01 2016-01-03 -F %Y/%m/%d
2016/01/01
2016/01/02
2016/01/03

Date format in command:

$ diter 2016-01-01 2016-01-03 -- echo date=%Y/%m/%d
date=2016/01/01
date=2016/01/02
date=2016/01/03

Refer to Date#strftime for possible date formats.

Parallel execution (with xargs):

$ diter 2016-01-01 2016-01-03 | xargs -I{} -P2 -t echo date={}
echo date=2016-01-01
echo date=2016-01-02
date=2016-01-01
date=2016-01-02
echo date=2016-01-03
date=2016-01-03

Loop:

$ for lang in en ja fr; do
>   for date in `diter 2016-01-01 2016-01-03`; do
>      echo lang=$lang date=$date
>   done
> done
lang=en date=2016-01-01
lang=en date=2016-01-02
lang=en date=2016-01-03
lang=ja date=2016-01-01
lang=ja date=2016-01-02
lang=ja date=2016-01-03
lang=fr date=2016-01-01
lang=fr date=2016-01-02
lang=fr date=2016-01-03

Filter by the day of week:

$ diter 2016-01-01 2016-01-31 --wday=1
2016-01-04
2016-01-11
2016-01-18
2016-01-25

Filter by the day of month:

$ diter 2016-01-01 2016-04-01 --mday=15
2016-01-15
2016-02-15
2016-03-15

A negative integer is assumed to be relative to the end of month:

$ diter 2016-01-01 2016-04-01 --mday=-1
2016-01-31
2016-02-29
2016-03-31