5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2017-08-17
+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} 初月以外
5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?