日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

测试工程师之【python】按工龄开始日期和司龄开始日期计算当年公司福利年假

發布時間:2023/12/14 python 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 测试工程师之【python】按工龄开始日期和司龄开始日期计算当年公司福利年假 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.腳本需求:
公司內部休假系統,計算規則比較復雜比較惡心,前期準備工作看看文檔什么的,想著自己寫一個一摸一樣類似的規則方便到時候給出工齡和司齡日期自動計算結果,省的到時候用計算器手工算了,另一方面是熟悉業務方便后期功能測試寫用例場景能想的全覆蓋的多一點
2.代碼實現及思路
需求文檔上有一部分示例場景了解的,概括來說就是未滿1年-已滿1年-等等等一直到第6年每滿一年都有對應的福利年假天數,在根據工齡什么時候時開始工作共多少天了當年有沒有跨檔,根據跨檔節點進行計算,猜測應該有bug,因為判斷條年寫死了,有誤差

import datetimedef welfare_annual_leave(working_years_Starttime,Secretary_Ling_Starttime):Small_10,Small_20 = 0,0Secretary_Ling_one,Secretary_Ling_two,Secretary_Ling_three,Secretary_Ling_four,Secretary_Ling_five,Secretary_Ling_six = 0,0,0,0,0,0working_years_Starttime = datetime.date(int(working_years_Starttime.split('-')[0]),int(working_years_Starttime.split('-')[1]),int(working_years_Starttime.split('-')[2]))Secretary_Ling_Starttime = datetime.date(int(Secretary_Ling_Starttime.split('-')[0]),int(Secretary_Ling_Starttime.split('-')[1]),int(Secretary_Ling_Starttime.split('-')[2]))if datetime.date(datetime.date.today().year,1,1).__sub__(Secretary_Ling_Starttime).days >= 0:That_year_1month1 = datetime.date(datetime.date.today().year,1,1)differ_day = That_year_1month1.__sub__(working_years_Starttime).dayswhile 1:if str(That_year_1month1) == str(That_year_1month1.year) + '-12-31':breakThat_year_1month1 += datetime.timedelta(days=1)differ_day += 1if differ_day == 3650:Small_10 = That_year_1month1elif differ_day == 7300:Small_20 = That_year_1month1That_year_1month1 = datetime.date(datetime.date.today().year,1,1)Straddle_day = That_year_1month1.__sub__(Secretary_Ling_Starttime).dayswhile 1:if str(That_year_1month1) == str(That_year_1month1.year) + '-12-31':breakThat_year_1month1 += datetime.timedelta(days=1)Straddle_day += 1if Straddle_day == 365:Secretary_Ling_one = That_year_1month1elif Straddle_day == 730:Secretary_Ling_two = That_year_1month1elif Straddle_day == 1095:Secretary_Ling_three = That_year_1month1elif Straddle_day == 1460:Secretary_Ling_four = That_year_1month1elif Straddle_day == 1825:Secretary_Ling_five = That_year_1month1elif Straddle_day == 2190:Secretary_Ling_six = That_year_1month1if Small_10:if Secretary_Ling_one:if Small_10.__sub__(Secretary_Ling_one).days == 0:return ((Small_10.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 3) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 1)elif Small_10.__sub__(Secretary_Ling_one).days > 0:return ((Secretary_Ling_one.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 3) + ((Small_10.__sub__(Secretary_Ling_one).days / 365) * 4) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 1)elif Small_10.__sub__(Secretary_Ling_one).days < 0:return ((Small_10.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 3) + ((Secretary_Ling_one.__sub__(Small_10).days / 365) * 0) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_one).days / 365) * 1)elif Secretary_Ling_two:if Small_10.__sub__(Secretary_Ling_two).days == 0:return ((Small_10.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 4) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 2)elif Small_10.__sub__(Secretary_Ling_two).days > 0:return ((Secretary_Ling_two.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 4) + ((Small_10.__sub__(Secretary_Ling_two).days / 365) * 5) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 2)elif Small_10.__sub__(Secretary_Ling_two).days < 0:return ((Small_10.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 4) + ((Secretary_Ling_two.__sub__(Small_10).days / 365) * 1) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_two).days / 365) * 2)elif Secretary_Ling_three:if Small_10.__sub__(Secretary_Ling_three).days == 0:return ((Small_10.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 5) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 3)elif Small_10.__sub__(Secretary_Ling_three).days > 0:return ((Secretary_Ling_three.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 5) + ((Small_10.__sub__(Secretary_Ling_three).days / 365) * 6) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 3)elif Small_10.__sub__(Secretary_Ling_three).days < 0:return ((Small_10.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 5) + ((Secretary_Ling_three.__sub__(Small_10).days / 365) * 2) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_three).days / 365) * 3)elif Secretary_Ling_four:if Small_10.__sub__(Secretary_Ling_four).days == 0:return ((Small_10.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 6) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 4)elif Small_10.__sub__(Secretary_Ling_four).days > 0:return ((Secretary_Ling_four.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 6) + ((Small_10.__sub__(Secretary_Ling_four).days / 365) * 7) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 4)elif Small_10.__sub__(Secretary_Ling_four).days < 0:return ((Small_10.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 6) + ((Secretary_Ling_four.__sub__(Small_10).days / 365) * 3) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_four).days / 365) * 4)elif Secretary_Ling_five:if Small_10.__sub__(Secretary_Ling_five).days == 0:return ((Small_10.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 7) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 5)elif Small_10.__sub__(Secretary_Ling_five).days > 0:return ((Secretary_Ling_five.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 7) + ((Small_10.__sub__(Secretary_Ling_five).days / 365) * 8) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 5)elif Small_10.__sub__(Secretary_Ling_five).days < 0:return ((Small_10.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 7) + ((Secretary_Ling_five.__sub__(Small_10).days / 365) * 4) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_five).days / 365) * 5)elif Secretary_Ling_six:if Small_10.__sub__(Secretary_Ling_six).days == 0:return ((Small_10.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 8) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 6)elif Small_10.__sub__(Secretary_Ling_six).days > 0:return ((Secretary_Ling_six.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 8) + ((Small_10.__sub__(Secretary_Ling_six).days / 365) * 9) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 6)elif Small_10.__sub__(Secretary_Ling_six).days < 0:return ((Small_10.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 8) + ((Secretary_Ling_six.__sub__(Small_10).days / 365) * 5) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_six).days / 365) * 6)elif Small_20:if Secretary_Ling_one:if Small_20.__sub__(Secretary_Ling_one).days == 0:return ((Small_20.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 0) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 1)elif Small_20.__sub__(Secretary_Ling_one).days > 0:return ((Secretary_Ling_one.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 0) + ((Small_20.__sub__(Secretary_Ling_one).days / 365) * 1) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 1)elif Small_20.__sub__(Secretary_Ling_one).days < 0:return ((Small_20.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 0) + ((Secretary_Ling_one.__sub__(Small_20).days / 365) * 0) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_one).days / 365) * 1)elif Secretary_Ling_two:if Small_20.__sub__(Secretary_Ling_two).days == 0:return ((Small_20.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 1) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 2)elif Small_20.__sub__(Secretary_Ling_two).days > 0:return ((Secretary_Ling_two.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 1) + ((Small_20.__sub__(Secretary_Ling_two).days / 365) * 2) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 2)elif Small_20.__sub__(Secretary_Ling_two).days < 0:return ((Small_20.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 1) + ((Secretary_Ling_two.__sub__(Small_20).days / 365) * 1) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_two).days / 365) * 2)elif Secretary_Ling_three:if Small_20.__sub__(Secretary_Ling_three).days == 0:return ((Small_20.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 2) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 3)elif Small_20.__sub__(Secretary_Ling_three).days > 0:return ((Secretary_Ling_three.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 2) + ((Small_20.__sub__(Secretary_Ling_three).days / 365) * 3) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 3)elif Small_20.__sub__(Secretary_Ling_three).days < 0:return ((Small_20.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 2) + ((Secretary_Ling_three.__sub__(Small_20).days / 365) * 2) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_three).days / 365) * 3)elif Secretary_Ling_four:if Small_20.__sub__(Secretary_Ling_four).days == 0:return ((Small_20.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 3) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 4)elif Small_20.__sub__(Secretary_Ling_four).days > 0:return ((Secretary_Ling_four.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 3) + ((Small_20.__sub__(Secretary_Ling_four).days / 365) * 4) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 4)elif Small_20.__sub__(Secretary_Ling_four).days < 0:return ((Small_20.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 3) + ((Secretary_Ling_four.__sub__(Small_20).days / 365) * 3) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_four).days / 365) * 4)elif Secretary_Ling_five:if Small_20.__sub__(Secretary_Ling_five).days == 0:return ((Small_20.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 4) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 5)elif Small_20.__sub__(Secretary_Ling_five).days > 0:return ((Secretary_Ling_five.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 4) + ((Small_20.__sub__(Secretary_Ling_five).days / 365) * 5) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 5)elif Small_20.__sub__(Secretary_Ling_five).days < 0:return ((Small_20.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 4) + ((Secretary_Ling_five.__sub__(Small_20).days / 365) * 4) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_five).days / 365) * 5)elif Secretary_Ling_six:if Small_20.__sub__(Secretary_Ling_six).days == 0:return ((Small_20.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 5) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 6)elif Small_20.__sub__(Secretary_Ling_six).days > 0:return ((Secretary_Ling_six.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 5) + ((Small_20.__sub__(Secretary_Ling_six).days / 365) * 6) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 5)elif Small_20.__sub__(Secretary_Ling_six).days < 0:return ((Small_20.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 5) + ((Secretary_Ling_six.__sub__(Small_20).days / 365) * 5) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_six).days / 365) * 5)elif differ_day < 3650:if Secretary_Ling_one:return ((Secretary_Ling_one.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 3) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_one).days / 365) * 4)elif Secretary_Ling_two:return ((Secretary_Ling_two.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 4) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_two).days / 365) * 5)elif Secretary_Ling_three:return ((Secretary_Ling_three.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 5) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_three).days / 365) * 6)elif Secretary_Ling_four:return ((Secretary_Ling_four.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 6) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_four).days / 365) * 7)elif Secretary_Ling_five:return ((Secretary_Ling_five.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 7) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_five).days / 365) * 8)elif Secretary_Ling_six:return ((Secretary_Ling_six.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 8) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_six).days / 365) * 9)elif 3650 < differ_day < 7300:if Secretary_Ling_one:return ((Secretary_Ling_one.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 0) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_one).days / 365) * 1)elif Secretary_Ling_two:return ((Secretary_Ling_two.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 1) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_two).days / 365) * 2)elif Secretary_Ling_three:return ((Secretary_Ling_three.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 2) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_three).days / 365) * 3)elif Secretary_Ling_four:return ((Secretary_Ling_four.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 3) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_four).days / 365) * 4)elif Secretary_Ling_five:return ((Secretary_Ling_five.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 4) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_five).days / 365) * 5)elif Secretary_Ling_six:return ((Secretary_Ling_six.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 5) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_six).days / 365) * 6)elif differ_day > 7300:if Secretary_Ling_one:return ((Secretary_Ling_one.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 0) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_one).days / 365) * 1)elif Secretary_Ling_two:return ((Secretary_Ling_two.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 1) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_two).days / 365) * 2)elif Secretary_Ling_three:return ((Secretary_Ling_three.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 2) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_three).days / 365) * 3)elif Secretary_Ling_four:return ((Secretary_Ling_four.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 3) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_four).days / 365) * 4)elif Secretary_Ling_five:return ((Secretary_Ling_five.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 4) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_five).days / 365) * 5)elif Secretary_Ling_six:return ((Secretary_Ling_six.__sub__(datetime.date(datetime.date.today().year,1,1)).days / 365) * 5) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_six).days / 365) * 5)else:Secretary_Ling_Starttime_1 = Secretary_Ling_Starttimediffer_day = Secretary_Ling_Starttime.__sub__(working_years_Starttime).days + 1while 1:if str(Secretary_Ling_Starttime) == str(Secretary_Ling_Starttime.year) + '-12-31':breakSecretary_Ling_Starttime += datetime.timedelta(days=1)differ_day += 1if differ_day == 3650:Small_10 = Secretary_Ling_Starttimeelif differ_day == 7300:Small_20 = Secretary_Ling_Starttimeif Small_10:if Small_10.__sub__(Secretary_Ling_Starttime_1).days == 0:return (datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_Starttime_1).days / 365) * 0elif Small_10.__sub__(Secretary_Ling_Starttime_1).days > 0:return ((Small_10.__sub__(Secretary_Ling_Starttime_1).days / 365) * 3) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_10).days / 365) * 0)elif Small_10.__sub__(Secretary_Ling_Starttime_1).days < 0:return (datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_Starttime_1).days / 365) * 0elif Small_20:if Small_20.__sub__(Secretary_Ling_Starttime_1).days == 0:return (datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_Starttime_1).days / 365) * 0elif Small_20.__sub__(Secretary_Ling_Starttime_1).days > 0:return ((Small_20.__sub__(Secretary_Ling_Starttime_1).days / 365) * 0) + ((datetime.date(datetime.date.today().year + 1,1,1).__sub__(Small_20).days / 365) * 0)elif Small_20.__sub__(Secretary_Ling_Starttime_1).days < 0:return (datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_Starttime_1).days / 365) * 0elif differ_day < 3650:return (datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_Starttime_1).days / 365) * 3elif 3650 < differ_day < 7300:return (datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_Starttime_1).days / 365) * 0elif differ_day > 7300:return (datetime.date(datetime.date.today().year + 1,1,1).__sub__(Secretary_Ling_Starttime_1).days / 365) * 0if __name__ == "__main__":print(welfare_annual_leave('2011-02-01','2019-12-01'))

總結

以上是生活随笔為你收集整理的测试工程师之【python】按工龄开始日期和司龄开始日期计算当年公司福利年假的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。