Skip to content

Instantly share code, notes, and snippets.

@wayneeseguin
Forked from chorn/date_range.bash
Created June 15, 2011 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wayneeseguin/1027088 to your computer and use it in GitHub Desktop.
Save wayneeseguin/1027088 to your computer and use it in GitHub Desktop.
#!/bin/bash
date_range() {
# Output list of dates from $1 to $2
}
for d in $(date_range 2011-01-01 2011-02-01) ; do
my_command $d
done
∴ cat $HOME/test
#!/usr/bin/env bash
source "/usr/local/bdsm/modules/bash/core/initialize" # Load BDSM framework
modules date
log "hour"
date_range 2011-01-01 2011-01-02 step hour format_out "%Y-%m-%dT%H"
log "day (default)"
date_range 2011-01-01 2011-02-01
log "month"
date_range 2011-01-01 2011-06-01 step month
log "year"
date_range 2011-01-01 2013-01-01 step year
10:06:14 wayneeseguin@localhost:~ rbx-head
∴ $HOME/test
hour
2011-01-01T10
2011-01-01T11
2011-01-01T12
2011-01-01T13
2011-01-01T14
2011-01-01T15
2011-01-01T16
2011-01-01T17
2011-01-01T18
2011-01-01T19
2011-01-01T20
2011-01-01T21
2011-01-01T22
2011-01-01T23
2011-01-02T00
2011-01-02T01
2011-01-02T02
2011-01-02T03
2011-01-02T04
2011-01-02T05
2011-01-02T06
2011-01-02T07
2011-01-02T08
2011-01-02T09
2011-01-02T10
day (default)
2011-01-01
2011-01-02
2011-01-03
2011-01-04
2011-01-05
2011-01-06
2011-01-07
2011-01-08
2011-01-09
2011-01-10
2011-01-11
2011-01-12
2011-01-13
2011-01-14
2011-01-15
2011-01-16
2011-01-17
2011-01-18
2011-01-19
2011-01-20
2011-01-21
2011-01-22
2011-01-23
2011-01-24
2011-01-25
2011-01-26
2011-01-27
2011-01-28
2011-01-29
2011-01-30
2011-01-31
2011-02-01
month
2011-01-01
2011-01-31
2011-03-02
2011-04-01
2011-05-01
2011-05-31
year
2011-01-01
2012-01-01
2012-12-31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment