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]);

Atitit.基于时间戳的农历日历历法日期计算的更多相关文章

  1. 带农历日历的DatePicker控件!Xamarin控件开发小记

    原文:带农历日历的DatePicker控件!Xamarin控件开发小记 闲来无事开发了个日期选择控件,感兴趣的同学前往: https://github.com/MatoApps/Mato.DatePi ...

  2. Atitit 基于sql编程语言的oo面向对象大规模应用解决方案attilax总结

    Atitit 基于sql编程语言的oo面向对象大规模应用解决方案attilax总结 1. Sql语言应该得到更大的范围的应用,1 1.1. 在小型系统项目中,很适合存储过程写业务逻辑2 1.2. 大型 ...

  3. jquery 农历日历 可自适应

    在网上找了许多大牛做的农历日历,但是不是不符合项目中的要求,就是本身就有问题有Bug ,把大牛门的做日历看了n遍 自己又改造了一遍得到了这个:随后日历又要做个自适应的长宽,又在js中改造代码..... ...

  4. Atitit 基于图片图像 与文档混合文件夹的分类

    Atitit 基于图片图像 与文档混合文件夹的分类 太小的文档(txt doc csv exl ppt pptx)单独分类 Mov10KminiDoc 但是可能会有一些书法图片迁移,因为他们很微小,需 ...

  5. Atitit  基于meta的orm,提升加速数据库相关应用的开发

    Atitit  基于meta的orm,提升加速数据库相关应用的开发 1.1. Overview概论1 1.2. Function & Feature功能特性1 1.2.1. meta api2 ...

  6. Atitit 基于dom的游戏引擎

    Atitit 基于dom的游戏引擎 1. 添加sprite控件(cocos,createjs,dom)1 1.1.1. Cocos1 1.1.2. createjs1 1.1.3. Dom模式2 1. ...

  7. Atitit.基于dsl的methodinvoker

    Atitit.基于dsl的methodinvoker V2 new dyn  invoke V3 plan Meth chain Prj  cms methd_invok.bat rem a  sta ...

  8. atitit.基于http json api 接口设计 最佳实践 总结o7

    atitit.基于http  json  api 接口设计 最佳实践 总结o7 1. 需求:::服务器and android 端接口通讯 2 2. 接口开发的要点 2 2.1. 普通参数 meth,p ...

  9. 25个有用的jQuery日历和日期选取插件

    jQuery被认为是最好的JavaScript库,因为它简单易用.灵活,并有大量的插件.本文介绍25个非常不错的jQuery日历和日期选取插件,希望对各位有用. 1. Simple JQuery Da ...

随机推荐

  1. nrf51822, How to use a vendor specific UUID?

    Using a vendor specific UUID is basically a two-step process: 1. Add your custom base UUID to the st ...

  2. iOS开源项目:AudioPlayer

    AudioPlayer是一个基于AVAudioStreamer的在线音乐播放软件. https://github.com/marshluca/AudioPlayer 首先将歌曲信息存储在NSArray ...

  3. iOS:UIApplication和它对象的代理

    <1>UIApplication的对象是单例对象   类方法:UIApplication *app = [UIApplication sharedAppplication] <2&g ...

  4. 关于QtCharts中的映射器与模型的使用

    简述 本文章基于博主在使用QtCharts中一些经验总结,相关了Qt类有QVXYModelMapper,CustomTableModel(一个继承了QAbstractTableModel的类,用于实现 ...

  5. Nicescroll滚动条插件的用法

    Nicescroll滚动条插件是一个非常强大的基于jQuery的滚动条插件,不需要增加额外的css,几乎全浏览器兼容.ie6+,实现只需要一段代码,侵入性非常小,样式可完全自定义,支持触摸事件,可在触 ...

  6. java.lang.IllegalArgumentException:Document base ……does not exist or is not a readable directory错误的解决方案

    关于Tomcat的 Document base ……does not exist or is not a readable directory错误 java.lang.IllegalArgumentE ...

  7. 全民Scheme(2):来自星星的你

    一门编程语言,假设不能对你思考编程的方式产生影响.就不值得去学习.--  Alan Perlis (define rember*   (lambda (a list)     (cond       ...

  8. html5-video视频播放

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/ ...

  9. (LeetCode 53)Maximum Subarray

    Find the contiguous subarray within an array (containing at least one number) which has the largest ...

  10. PHP phpMyadmin数据库备份太大无法导入怎么

    1 如图所示,phpMyAdmin的数据库最大只能8M,大于这个体积就无法导入 2 你可以从以下网站下载这个软件Navicat for MySQL, http://www.pb86.net/soft/ ...