Giter Club home page Giter Club logo

chinese-calendar's Introduction

Lirian Su(LKI)'s Configuration, 我的配置

Build Status PyPI PyPI

你好,我是苏子岳。 我的开发环境是 Windows 系统, 但我也时常会在 Unix 系统上游荡 (云服务器或者是 WSL)。 因为经常折腾环境, 所以我专门开了一个项目来同步我的各类配置。 很不巧,这个叫做 LKI 的项目后来被 GitHub 当作了同名自我介绍项目了, 假如你对我本人感兴趣,可以读一下我的自我介绍

配置风格

我很懒, 主要使用各类缩写、热键执行命令。 这个项目包含了大量缩写, 但这些改动都是额外附加的, 它们并不改变原有的命令习惯。

为了方便安装, 我把配置安装过程写成了 python 脚本。 (所以我拿到电脑第一时间是装一个 python 环境)

快速安装

首先,确保环境中有 Python 3.7+,然后使用 pip 快速安装:

pip install lki && lki install

本命令同时支持 Unix, MacOS, Windows 环境 发现有问题就给我报 Issue

使用指南

~/.gitconfig 中包含了大量的 git alias:

# 查看 git 配置
$ cat ~/.gitconfig

# git 的基础缩写
$ git ci  # `git commit`
$ git br  # `git branch`
$ git pf  # `git push -f`
$ git sv  # `git save` <=> `git stash`
$ git ld  # `git load` <=> `git stash pop`

# git 的常用缩写
$ git cm    # amend last commit
$ git logg  # log ing graph
$ git pd    # push dev with gitlab merge request created
$ git yes   # show what happened yesterday

~/.profile 中包含了大量的 bash alias:

# 查看 bash 配置
$ cat ~/.profile

# 常用缩写
$ please visudo  # `sudo visudo`
$ g st  # `git status`
$ pv sync --dev  # `pipenv sync --dev`

# 子命令复合缩写
$ dpa  # `docker ps -a`
$ kgp  # `kubectl get pods`
$ gcm  # `git cm`
$ gsh  # ssh through gate

# 个人向的,你们用不上的缩写
# 我写这就是给你们看看我平常跑那些命令
$ svl  # go into my blog repo
$ dspm test  # run django test for zaihui/server project
$ stp  # exec bash into k8s cluster

Vim 的配置,参见另外一个项目 LKI/dotvim

关于本项目的功能还有很多, 但是这里的空白太少我写不下了 XD

开源协议

宽松的 MIT License, 意味着你可以做任何更改, 甚至把作者名都改成你。

我有问题要问

没关系,不论是对项目的问题还是对我个人的问题, 或者是你觉得哪条命令不够好用, 都欢迎来项目里直接提 Issue。

chinese-calendar's People

Contributors

calfzhou avatar dependabot[bot] avatar dragon-gcs avatar fhrl94 avatar ldsink avatar lijingcheng3359 avatar lki avatar luzihang123 avatar xiaomingtt avatar yqkcn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chinese-calendar's Issues

2019劳动节更新模块

最新的 12.2版本模块 劳动节2019好像没更新上,还是之前的 ,方便更新下吗

2005年holiday判断问题

您好,在对2005年-2013年日期进行判断时发现很多个周末会被判断为节假日
例如is_holiday(datetime.date(2005, 1, 16)) 返回True
chinese_calendar.get_holiday_detail(datetime.date(2005, 1, 16)) 返回(True, None)
这是什么情况呢

python 2.7.5 install chinesecalendar error

Downloading chinesecalendar-1.5.1.tar.gz (9.4 kB)
ERROR: Command errored out with exit status 1:
command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/tc/cls8jwsn6fd6hvmph42vxyp00000gn/T/pip-install-ZdYNb5/chinesecalendar/setup.py'"'"'; file='"'"'/private/var/folders/tc/cls8jwsn6fd6hvmph42vxyp00000gn/T/pip-install-ZdYNb5/chinesecalendar/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/tc/cls8jwsn6fd6hvmph42vxyp00000gn/T/pip-pip-egg-info-e9vti7
cwd: /private/var/folders/tc/cls8jwsn6fd6hvmph42vxyp00000gn/T/pip-install-ZdYNb5/chinesecalendar/
Complete output (5 lines):
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/tc/cls8jwsn6fd6hvmph42vxyp00000gn/T/pip-install-ZdYNb5/chinesecalendar/setup.py", line 6, in
with open("README.md", "r", encoding="utf-8") as f:
TypeError: 'encoding' is an invalid keyword argument for this function
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

节假日

之后的节假日是需要手动添加吗,还是说会自动去爬取后边公布的节假日

希望支持 Python 3.7

python3 -m pip install chinese_calendar
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
ERROR: Could not find a version that satisfies the requirement chinese_calendar (from versions: none)
ERROR: No matching distribution found for chinese_calendar

既然支持 Python 3.6,3.7 下运行应该也没问题的

能否增加农历日子的判断

我每天有写计划和日志的习惯,希望能借助这个程序包实现农历信息的判断,方便我在写日志的时候,能自动提醒是哪个亲人的生日。

是否可以加入法定节假日和调休日区分呢?

按照国家加班工资规定:
在法定节假日,用人单位应当按照不低于日工资基数或者小时工资基数的300%来支付加班工资,而且不得以调休、补休替代。在休息日,用人单位应当先安排同等时间的补休;确实不能安排补休的,要按照不低于日工资基数或者小时工资基数的200%支付加班工资。

根据国家统一安排,2018年春节放假共七天,即2月15日至21日。其中,国家法定节假日有三天,即2月16日到18日,也就是农历正月初一、初二、初三;另外有四天是调休日,即2月15日、19日、20日、21日,这是由2月11日、17日、18日、24日这四个周末休息日调过来的。

也就是说,同样是节假日,法定假日和调休日的加班工资是不一样的。我这边做个项目,就要根据这个区分工资计算。

麻烦大神看下是否能支持?我不是专业搞python的。怕提交的代码不规范

判断某一天是否为节假日当天

现在发现一个问题,比如国庆节七天假,十月一号返回节日名称没问题,但是之后的几天加也会返回国庆节,虽也说得过去,但是如果要实现在节日当天发送祝福语的话,就不能以此为准了,在十月一日之后的几天节日里每天提醒国庆节是不大合适的。烦请指点是否存在可区分实际节日当天和假日的解决方案
today = datetime.now()
on_holiday, holiday_name = calendar.get_holiday_detail(today)
return on_holiday, holiday_name

支持多种输入

  1. 支持其他时间表示方式:"2018-01-01" pandas.timestamp等
  2. 支持list, numpy.Array, pd.Series输入,提取时间特征

调休的定义是?

这个调休第一眼看过去有点奇怪

image

chinese_calendar.is_in_lieu(date(2018,9,30))
False
chinese_calendar.is_in_lieu(date(2018,10,1))
False
chinese_calendar.is_in_lieu(date(2018,10,2))
False
chinese_calendar.is_in_lieu(date(2018,10,3))
False
chinese_calendar.is_in_lieu(date(2018,10,4))
True
chinese_calendar.is_in_lieu(date(2018,10,5))
True
chinese_calendar.is_in_lieu(date(2018,10,6))
False
chinese_calendar.is_in_lieu(date(2018,10,7))
False

9.29, 9.30 休调班
10,4,10,5 班调休

一般是说 9.29, 9.30 调休到 10,4,10,5
这样区分下会更好吧

建议统一一下节假日是否包含周末

目前看constants.py,节假日有的包含了连休的周末,有的没有包含,如2017年5月1日是劳动节,而2018年4月29、30和5月1日都是劳动节,是否可以统一一下?

calendar.get_holiday_detail error

我不知道底层怎么实现的,但是这个判断春节有明显的错误。
例如 2017-1-22 跟春节不搭边,却判断的是春节

你忘了把 `requirements.txt` 包到 pypi 发布包里

Detail :
image

>>> pip install chinesecalendar -U
Collecting chinesecalendar
  Downloading https://files.pythonhosted.org/packages/85/c4/893db136ff403f2194ef664e19211712efdaa50de91762543a40e22ee827/chinesecalendar-1.2.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\xxxxx\AppData\Local\Temp\pip-install-fxjk3a1v\chinesecalendar\setup.py", line 4, in <module>
        with open('requirements.txt') as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'requirements.txt'

考虑使用更科学的接口

目前的方式是

import datetime

from chinese_calendar.utils import is_workday, is_holiday

march_first = datetime.date(2017, 5, 1)

print(is_workday(march_first))  # False

print(is_holiday(march_first))  # True

其实可以改成

import datetime

import chinese_calendar

march_first = datetime.date(2017, 5, 1)

print(chinese_calendar.is_workday(march_first))  # False

print(chinese_calendar.is_holiday(march_first))  # True

节假日判断混乱。

用get_holiday_detail函数输出是否是节假日以及节假日名称时非常混乱。
比如 劳动节,只有2017-05-01号有name输出
而端午节,反而有2017-05-27到2017-05-30都算端午节,有name输出。

不调休判断假日与周末

金融行业中,就算是因为调休周末需要工作时,也是休息,不工作的。能否加个参数来忽略周末调休的情况?

比如 2020年2月1日:

chinese_calendar.is_holiday(datetime.date(2020,2,1))
False

实际这是一个周六,也是假日。

清明节节假日错误

比如datetime.date(2014, 4, 7)应该是清明节放假日,但实际datetime.date(2014, 4, 7)返回False

判断节假日的bug

判断 4月5日是否是节假日

march_first = today + datetime.timedelta(days=1)
is_workday(march_first)  

输出 FALSE
工作日和节假日判断错误。
原因是 march_first 是 datetime 类,不是 date 类。
但是 datetime 类才有 timedelta方法,进行日期的计算。
将 march_first 转换为 date 类。
示例代码如下

march_first = today + datetime.timedelta(days=1)
is_workday(march_first.date())

如果可以的话,将上面的的示例代码进行修改。。。。
或者将 datetime 类进行强制转换为 date 类。 @LKI

关于更新日期问题

如果要使用最新的日期,像现在马上要2022年了,是不是必须要更新版本才可以取到2022年的日期数据呀

这个不是issue,这个是感谢信!

接近年底,定时任务突然报错,如不处理后果非常严重。查看程序报错原因为支持年份[2014, 2018],于是赶紧来到GitHub查看是否有更新,结果发现lz更新了啊啊啊啊!非常感谢您!

Bug 2006-12-31

调用is_holiday(datetime.date(2005,12,31)) ,返回True,但那天是调休上班,类似的问题貌似还有

python2.7 导入报错

from chinese_calendar import is_holiday, is_workday
Traceback (most recent call last):
File "", line 1, in
File "/home/zhangyuzhou/Downloads/pycharm-community/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/zhangyuzhou/PycharmProjects/CmeomsSpider/env/local/lib/python2.7/site-packages/chinese_calendar/init.py", line 4, in
from .constants import Holiday
File "/home/zhangyuzhou/Downloads/pycharm-community/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/zhangyuzhou/PycharmProjects/CmeomsSpider/env/local/lib/python2.7/site-packages/chinese_calendar/constants.py", line 31, in
datetime.date(year=2006, month=1, day=1): Holiday.new_years_day.value,
AttributeError: 'tuple' object has no attribute 'value'

判断是否是有休息的特殊节日

因为目前没有这个接口,所以只能查节日名 ,
但是我在数据里发现有个这个

    datetime.date(year=2015, month=9, day=3): Holiday.anti_fascist_70th_day.value,
    datetime.date(year=2015, month=9, day=4): Holiday.anti_fascist_70th_day.value,

我不记得15年有休过这个假日。。。
因为我是做数据分析的,要把特殊休息的节假日剔除掉,所以有用。


百度了一下,有说当时有调休。。。搞不清楚了

pip install chinesecalendar==1.2.1 错误

[root@localhost SMSBlessing_web]# pip3.6 install chinesecalendar==1.2.1
Collecting chinesecalendar==1.2.1
  Using cached https://files.pythonhosted.org/packages/8a/16/3581d813287b8d9db7deaf6e300dae2789d74acb73906c40996e35e5ff43/chinesecalendar-1.2.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-1xed56d2/chinesecalendar/setup.py", line 2, in <module>
        import pypandoc
    ModuleNotFoundError: No module named 'pypandoc'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-1xed56d2/chinesecalendar/
[root@localhost SMSBlessing_web]# pip3.6 install chinesecalendar==1.2.1
Collecting chinesecalendar==1.2.1
  Using cached https://files.pythonhosted.org/packages/8a/16/3581d813287b8d9db7deaf6e300dae2789d74acb73906c40996e35e5ff43/chinesecalendar-1.2.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-7687iy1t/chinesecalendar/setup.py", line 2, in <module>
        import pypandoc
    ModuleNotFoundError: No module named 'pypandoc'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-7687iy1t/chinesecalendar/

2015年端午节错误

datetime.date(year=2015, month=6, day=20): Holiday.dragon_boat_festival.value,
datetime.date(year=2015, month=6, day=22): Holiday.dragon_boat_festival.value,

五、端午节:6月20日放假,6月22日(星期一)补休。
http://www.gov.cn/zhengce/content/2014-12/16/content_9302.htm

应该是

datetime.date(year=2015, month=6, day=20): Holiday.dragon_boat_festival.value,
datetime.date(year=2015, month=6, day=21): Holiday.dragon_boat_festival.value,
datetime.date(year=2015, month=6, day=22): Holiday.dragon_boat_festival.value,

以下这几个节假日有缺失

lose_holiday = {
'2019-06-08': 'Dragon Boat Festival',
'2019-06-09': 'Dragon Boat Festival',
'2019-09-14': 'Mid-autumn Festival',
'2019-09-15': 'Mid-autumn Festival',
'2019-09-21': 'Mid-autumn Festival',
'2019-04-06': 'Tomb-sweeping Day',
'2019-04-07': 'Tomb-sweeping Day',
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.