欧美日韩国产一区,亚洲一区视频,色综合久久久久,私密按摩师舌头伸进去了,99re6这里只有精品,夜夜性日日交xxx性hd

將時(shí)間戮轉(zhuǎn)化上午,下午,星期幾等文字

  • • 發(fā)表于 8年前
  • • 作者 劉冰華
  • • 4386 人瀏覽
  • • 2 條評(píng)論
  • • 最后編輯時(shí)間 8年前
  • • 來自 [技 術(shù)]

原創(chuàng)聲明:本文為作者原創(chuàng),未經(jīng)允許不得轉(zhuǎn)載,經(jīng)授權(quán)轉(zhuǎn)載需注明作者和出處

轉(zhuǎn)載請(qǐng)注明出處

作者:劉冰華
2016-12-8 13:00

在公用模塊方法中添加如下轉(zhuǎn)換類:

  //轉(zhuǎn)化時(shí)間成文字
function ChangeTimeToText (timeStamp){

      this.now = new Date(),this.nowTime = this.now.getTime();
      this.nowDay = this.now.getDate();              //當(dāng)前日
      this.nowMonth = this.now.getMonth();           //當(dāng)前月
      this.nowYear = this.now.getFullYear();             //當(dāng)前年

      this.nowDayOfWeek = this.now.getDay();         //今天本周的第幾天
      this.arr = ['日','一','二','三','四','五','六'];
      this.getWeekStartDate = new Date(this.nowYear, this.nowMonth, this.nowDay - this.nowDayOfWeek).getTime();//本周開始日期
      this.getCurrentDate = new Date(this.nowYear, this.nowMonth, this.nowDay).getTime();//今天開始日期
      this.getTomorowDate = new Date(this.nowYear, this.nowMonth, this.nowDay+1).getTime()-1;//今天結(jié)束日期
      this.nowAm = this.getCurrentDate + 12*3600*1000;//今天上午結(jié)束
      this.nowPm = this.getCurrentDate + 18*3600*1000;//今天下午結(jié)束
      this.nowEvening = this.getCurrentDate + 24*3600*1000;//今天晚上結(jié)束
      this.yesAm = this.getCurrentDate - 24*3600*1000;//昨天上午開始

    }
ChangeTimeToText.prototype.changeTimeToText = function(timeStamp){
    var t = parseInt(timeStamp);
    var timeStamp = new Date(timeStamp);
    var nowText = 0,resu='';
    var resHour = timeStamp.getHours();
    var resMinutes = timeStamp.getMinutes();
    var restime = (resHour < 12 ? '上午' + resHour : (resHour == 12 ? '下午' + resHour : resHour < 18 ? '下午' + (resHour-12) : '晚上' + (resHour-12))) + ':' + (resMinutes < 10 ? '0' + resMinutes : resMinutes);

    if(t >= this.getTomorowDate || t < this.getWeekStartDate){
        var mon = timeStamp.getMonth() + 1;
        mon = mon < 10 ? '0'+mon : mon;
        resu = timeStamp.getFullYear() + '年' + mon + '月' + timeStamp.getDate() + '日 ' + restime;
    }else if( t >= this.getCurrentDate){
        //如果是今天
        resu = restime;

    }else if( t >= this.yesAm){          
            resu = '昨天 ' + restime;          
    }else if( t >= this.getWeekStartDate){
        resu = '星期' + this.arr[timeStamp.getDay()] +' ' + restime;
    }else{
        var mon = timeStamp.getMonth() + 1;
        mon = mon < 10 ? '0'+mon : mon;
        resu = timeStamp.getFullYear() + '年' + mon + '月' + timeStamp.getDate() + '日 ' + restime;
    }

    return resu;
}
//對(duì)比時(shí)間3分鐘內(nèi)創(chuàng)建新時(shí)間
ChangeTimeToText.prototype.campareTime = function(s,e){
    return (e - s - 180000) > 0 ? true : false;
};



/*
* 暴露接口給外部
*/
module.exports = {ChangeTimeToText};

在用到的地方,諣用此方法

const ChangeTimeToText = new (require("../../pages/index/common")).ChangeTimeToText();
     console.log(ChangeTimeToText.changeTimeToText(1480442400000),'上午2:00');
     console.log(ChangeTimeToText.changeTimeToText(1480471200000),'上午10點(diǎn)');
     console.log(ChangeTimeToText.changeTimeToText(1480478460000),'下午12:01');
     console.log(ChangeTimeToText.changeTimeToText(1480489260000),'下午15:01');
     console.log(ChangeTimeToText.changeTimeToText(1480402860000),'昨天下午15:01');
     console.log(ChangeTimeToText.changeTimeToText(1480316460000),'星期一下午15:01');
     console.log(ChangeTimeToText.changeTimeToText(1480230060000),'27號(hào)15:01');
     console.log(ChangeTimeToText.changeTimeToText(1482832860000),'12月27下午18:01');
分享到:
2條評(píng)論
Ctrl+Enter
作者

劉冰華

劉冰華

APP:0 帖子:15 回復(fù):29 積分:953

已加入社區(qū)[3091]天

屌絲男士

作者詳情》
Top