Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
6
Help us understand the problem. What is going on with this article?

More than 3 years have passed since last update.

@pilot

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} 初月以外
6
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
6
Help us understand the problem. What is going on with this article?