我的日期字段(使用Luxon)不会给我正确的日期(应该是15日的1号)

时间:2019-10-03 20:19:44

标签: javascript vue.js luxon

我无法在日期字段的日期部分显示15个中的1个日期,具体取决于该月的时间。我已经使它以相同的方式工作了很多次,我不确定我缺少什么。有任何想法吗?寻找第二种可能的方法。

             <div class="col-lg-6">
              <div class="form-group">
                <label>Lease Term <span class="note">I</span></label>
                <input type="text" class="form-control" @change="leaseTermCalculator" v-model="document.lease_term">
              </div>
            </div>
            <div class="col-lg-6">
              <div class="form-group">
                <label>Lease Start <span class="note">I </span><span class="green pointer" v-on:click="document.lease_start = ''" v-if="document.lease_start != ''">x</span></label>
                <datetime type="date"
                          v-model="document.lease_start"
                          zone="UTC"
                          :change="leaseStartDay"
                          :format="{ year: 'numeric', month: 'long', day: 'numeric' }"
                          :phrases="{ok: 'OK', cancel: 'Cancel'}"
                          :minute-step="15"
                          use12-hour
                          auto
                          input-class="form-control"
                >
                </datetime>
              </div>
            </div>
            <div class="col-lg-6">
              <div class="form-group">
                <label>Lease End <span class="note">I </span><span class="green pointer" v-on:click="document.lease_end = ''" v-if="document.lease_end != ''">x</span></label>
                <datetime type="date"
                          v-model="document.lease_end"
                          zone="UTC"
                          :format="{ year: 'numeric', month: 'long', day: 'numeric' }"
                          :phrases="{ok: 'OK', cancel: 'Cancel'}"
                          :minute-step="15"
                          use12-hour
                          auto
                          input-class="form-control"
                >
                </datetime>
              </div>
            </div>
              </div>
      leaseStartDay() {
        var date = DateTime.fromISO(this.document.lease_start);
        var day = date.day;
        // console.log(day);
        if(day < 14) {
          this.document.lease_start = DateTime.fromISO(this.document.lease_start).set({day: 15});
          this.document.lease_start_day = 'FIFTEEN'
        } else{ 
          this.document.lease_start = DateTime.fromISO(this.document.lease_start).plus({months:1}).set({day: 1});
          this.document.lease_start_day = 'FIRST'
        }
      },
          mounted() {
        this.$parent.$on('documentHellosignUpdate', this.documentHellosignUpdate);
        this.leaseStartDay();
        setTimeout(() => { this.loaded = true; }, 1000);
      },

0 个答案:

没有答案