弃用警告:当我使用moment.js获取当前日期时,时刻构造回落到js日期

时间:2015-09-04 07:43:27

标签: javascript momentjs

我用moment.js获取当前日期。这是代码:

$(document).ready(function() {
    var date = moment().format("YYYY/MM/DD");
    console.log(date);
    $('#calendar').fullCalendar({
        theme: true,
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        defaultDate: date,
        editable: true,
        eventLimit: true // allow "more" link when too many event
    });

});

我在控制台中获得当前日期以及此警告:

Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.  

所以我添加了这样的ISO标签:

var date = moment().format("YYYY/MM/DD", "ddd, YYYY MM DD HH:mm:ss ZZ");  

但是我得到了同样的警告。如何删除此警告?

1 个答案:

答案 0 :(得分:1)

我没有使用上面的代码收到警告。我能够使用不同的语法来引发警告:

    viewPager.setPageTransformer(false, new ViewPager.PageTransformer() {
        @Override
        public void transformPage(View page, float position) {
            int pageWidth = viewPager.getMeasuredWidth() - viewPager.getPaddingLeft() - viewPager.getPaddingRight();
            int pageHeight = viewPager.getHeight();
            int paddingLeft = viewPager.getPaddingLeft();
            float transformPos = (float) (page.getLeft() - (viewPager.getScrollX() + paddingLeft)) / pageWidth;

            final float normalizedposition = Math.abs(Math.abs(transformPos) - 1);
            page.setAlpha(normalizedposition + 0.5f);

            int max = -pageHeight / 10;

            if (transformPos < -1) { // [-Infinity,-1)
                // This page is way off-screen to the left.
                page.setTranslationY(0);
            } else if (transformPos <= 1) { // [-1,1]
                page.setTranslationY(max * (1-Math.abs(transformPos)));

            } else { // (1,+Infinity]
                // This page is way off-screen to the right.
                page.setTranslationY(0);
            }


        }
    });

http://plnkr.co/edit/zHvLm3XPkWKLSRI50UON