嵇爾的吐槽

#没事画轮子的嵇尔不定期的(W)碎(E)碎(B)念(B)和(L)吐(O)槽(G)

关于某些的小工具 2017-08-02 17:33:00

最近因为某些那啥的事儿,好多事情都给搁置了,包括学锯子之类的各种事情

今天想动动爪子,不想给某些网站添加流量了

   
       
   
   

源代码

<script type="text/javascript">
    var currentDate = new Date();
    document.getElementById('startDate').value = currentDate.getFullYear() + '-' + formatPad(currentDate.getMonth() + 1) + '-' + formatPad(currentDate.getDate());

    function formatPad(string) {
        var pad = "00";
        string = String(string);
        return pad.substring(0, pad.length - string.length) + string;
    }

    function getResult() {
        var now = new Date();
        var start = new Date(document.getElementById('startDate').value);
        var result = new Date(start);
        result.setDate(start.getDate() + 280);
        document.getElementById('resultDate').value = result.getFullYear() + '-' + formatPad(result.getMonth() + 1) + '-' + formatPad(result.getDate());

        var week = (now - start) / 1000 / 60 / 60 / 24 / 7;
        var day = Math.floor((week - Math.floor(week)) * 7);
        document.getElementById('currentWeek').value = Math.floor(week) +"W";
        if (day > 0) {
            document.getElementById('currentWeek').value = document.getElementById('currentWeek').value + "+" + day;
        }
    }
</script>
评论共