Atitit.基於時間戳記的農曆日曆曆法日期計算,atitit曆法

來源:互聯網
上載者:User

Atitit.基於時間戳記的農曆日曆曆法日期計算,atitit曆法

 

Atitit.基於時間戳記的農曆日曆曆法日期計算

 

 

1. 農曆xx年的大小月份根據萬年曆查詢1

2. 農曆xx年1月1日的時間戳記擷取1

3. 計算當年的時間戳記與農曆日期的對應表,時間戳記為key,日期為val1

4. 根據擷取的時間戳記得到農曆日期2

 

 

1.  農曆xx年的大小月份根據萬年曆查詢

 

2006 年大進的月份13689,11,12

閏月的月份 none

小金月份2457,10

 

2.  農曆xx年1月1日的時間戳記擷取

農曆2016年1月1日,換算為西曆的2016-02-08 ,擷取時間戳記(sec為單位)

2016-02-08 00:00:01的時間戳記為:1454860801

 

// 擷取某個時間格式的時間戳記

var stringTime = "2016-02-08 00:00:01";

var timestamp2 = Date.parse(new Date(stringTime));

timestamp2 = timestamp2 / 1000;

//2014-07-10 10:21:12的時間戳記為:1404958872

console.log(stringTime + "的時間戳記為:" + timestamp2);

 

精確到天的時間戳記 16838.66667824074 天

 

 

作者::  ★(attilax)>>>   綽號:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿爾 拉帕努伊 ) 漢字名:艾龍,  EMAIL:1466519819@qq.com

轉載請註明來源: http://www.cnblogs.com/attilax/

 

3.  計算當年的時間戳記與農曆日期的對應表,時間戳記為key,日期為val

 var base=16838;

var lit_a=[2,4,5,7,10];

var map={};

var map_abs={};

var offset=1;

for(var i=1;i<=12;i++)

{

for(var j=1;j<=30;j++)

{

map[offset]=i+"-"+j;

map_abs[offset+base]=i+"-"+j;

console.log(" offset:"+offset+"    date:"+map[offset]);

offset++;

   if(lit_a.indexOf(i)>-1) //if mon is litt mon

   {

   if(j>=29)

break;

   }

   }

 

}

 

4.  根據擷取的時間戳記得到農曆日期

function getNowDateTmstmp()

{

 

 

var timestamp = Date.parse(new Date());

   timestamp=timestamp/(3600*24*1000);

   return Math.floor(timestamp);

}

 

 

var nowStmp_date=getNowDateTmstmp();

alert( map_abs[nowStmp_date]);

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.