6
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

Digdagで日付でループ ※イマイチ

+repeat:
  loop>: ${ moment("2016-12-31").diff(moment("2015-01-01"), 'days') + 1 }
  _do:
    echo>: ${ moment("2015-01-01").add(i, 'days').format("YYYY-MM-DD") }

for_eachに日付の配列渡そうと思ったけど${}内にそういう配列を作成するJSを書けず挫折

月毎にループするなら以下

_export:
  start_day   : 2016-01-31
  end_day     : 2016-03-01

+repeat:
  _export:
    start_month: ${moment(start_day).format("YYYY-MM-01")}
    end_month  : ${moment(end_day)  .format("YYYY-MM-01")}
  loop>: ${moment(end_month).diff(moment(start_month), 'month') + 1}
  _do:
    _export:
      month: ${moment(start_month).add(i, 'months').format("YYYY-MM")}
    +first_month:
      if>: ${i == 0}
      _do:
        echo>: ${month} 初月
    +not_first_month:
      if>: ${i != 0}
      _do:
        echo>: ${month} 初月以外

Register as a new user and use Qiita more conveniently

  1. You can follow users and tags
  2. you can stock useful information
  3. You can make editorial suggestions for articles
What you can do with signing up
6
Help us understand the problem. What are the problem?