Last active
October 11, 2024 06:07
-
-
Save mokejp/b1e735c5634bc27bbcdc to your computer and use it in GitHub Desktop.
六曜の処理 python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from datetime import date, timedelta | |
# 六曜リスト | |
ROKUYO_TABLE = ['大安', '赤口', '先勝', '友引', '先負', '仏滅'] | |
# 月別六曜開始位置リスト | |
ROKUYO_MONTH = [2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1] | |
# 新暦→旧暦の変換テーブル | |
OLD_MONTH_TSUITACHI_TABLE = { | |
2000: [ | |
(date(1999, 12, 8), (1999, 11)), | |
(date(2000, 1, 7), (1999, 12)), | |
(date(2000, 2, 5), (2000, 1)), | |
(date(2000, 3, 6), (2000, 2)), | |
(date(2000, 4, 5), (2000, 3)), | |
(date(2000, 5, 4), (2000, 4)), | |
(date(2000, 6, 2), (2000, 5)), | |
(date(2000, 7, 2), (2000, 6)), | |
(date(2000, 7, 31), (2000, 7)), | |
(date(2000, 8, 29), (2000, 8)), | |
(date(2000, 9, 28), (2000, 9)), | |
(date(2000, 10, 27), (2000, 10)), | |
(date(2000, 11, 26), (2000, 11)), | |
(date(2000, 12, 26), (2000, 12)), | |
], | |
2001: [ | |
(date(2000, 12, 26), (2000, 12)), | |
(date(2001, 1, 24), (2001, 1)), | |
(date(2001, 2, 23), (2001, 2)), | |
(date(2001, 3, 25), (2001, 3)), | |
(date(2001, 4, 24), (2001, 4)), | |
(date(2001, 5, 23), (2001, 4.5)), | |
(date(2001, 6, 21), (2001, 5)), | |
(date(2001, 7, 21), (2001, 6)), | |
(date(2001, 8, 19), (2001, 7)), | |
(date(2001, 9, 17), (2001, 8)), | |
(date(2001, 10, 17), (2001, 9)), | |
(date(2001, 11, 15), (2001, 10)), | |
(date(2001, 12, 15), (2001, 11)), | |
], | |
2002: [ | |
(date(2001, 12, 15), (2001, 11)), | |
(date(2002, 1, 13), (2001, 12)), | |
(date(2002, 2, 12), (2002, 1)), | |
(date(2002, 3, 14), (2002, 2)), | |
(date(2002, 4, 13), (2002, 3)), | |
(date(2002, 5, 12), (2002, 4)), | |
(date(2002, 6, 11), (2002, 5)), | |
(date(2002, 7, 10), (2002, 6)), | |
(date(2002, 8, 9), (2002, 7)), | |
(date(2002, 9, 7), (2002, 8)), | |
(date(2002, 10, 6), (2002, 9)), | |
(date(2002, 11, 5), (2002, 10)), | |
(date(2002, 12, 4), (2002, 11)), | |
], | |
2003: [ | |
(date(2002, 12, 4), (2002, 11)), | |
(date(2003, 1, 3), (2002, 12)), | |
(date(2003, 2, 1), (2003, 1)), | |
(date(2003, 3, 3), (2003, 2)), | |
(date(2003, 4, 2), (2003, 3)), | |
(date(2003, 5, 1), (2003, 4)), | |
(date(2003, 5, 31), (2003, 5)), | |
(date(2003, 6, 30), (2003, 6)), | |
(date(2003, 7, 29), (2003, 7)), | |
(date(2003, 8, 28), (2003, 8)), | |
(date(2003, 9, 26), (2003, 9)), | |
(date(2003, 10, 25), (2003, 10)), | |
(date(2003, 11, 24), (2003, 11)), | |
(date(2003, 12, 23), (2003, 12)), | |
], | |
2004: [ | |
(date(2003, 12, 23), (2003, 12)), | |
(date(2004, 1, 22), (2004, 1)), | |
(date(2004, 2, 20), (2004, 2)), | |
(date(2004, 3, 21), (2004, 2.5)), | |
(date(2004, 4, 19), (2004, 3)), | |
(date(2004, 5, 19), (2004, 4)), | |
(date(2004, 6, 18), (2004, 5)), | |
(date(2004, 7, 17), (2004, 6)), | |
(date(2004, 8, 16), (2004, 7)), | |
(date(2004, 9, 14), (2004, 8)), | |
(date(2004, 10, 14), (2004, 9)), | |
(date(2004, 11, 12), (2004, 10)), | |
(date(2004, 12, 12), (2004, 11)), | |
], | |
2005: [ | |
(date(2004, 12, 12), (2004, 11)), | |
(date(2005, 1, 10), (2004, 12)), | |
(date(2005, 2, 9), (2005, 1)), | |
(date(2005, 3, 10), (2005, 2)), | |
(date(2005, 4, 9), (2005, 3)), | |
(date(2005, 5, 8), (2005, 4)), | |
(date(2005, 6, 7), (2005, 5)), | |
(date(2005, 7, 6), (2005, 6)), | |
(date(2005, 8, 5), (2005, 7)), | |
(date(2005, 9, 4), (2005, 8)), | |
(date(2005, 10, 3), (2005, 9)), | |
(date(2005, 11, 2), (2005, 10)), | |
(date(2005, 12, 2), (2005, 11)), | |
(date(2005, 12, 31), (2005, 12)), | |
], | |
2006: [ | |
(date(2005, 12, 31), (2005, 12)), | |
(date(2006, 1, 29), (2006, 1)), | |
(date(2006, 2, 28), (2006, 2)), | |
(date(2006, 3, 29), (2006, 3)), | |
(date(2006, 4, 28), (2006, 4)), | |
(date(2006, 5, 27), (2006, 5)), | |
(date(2006, 6, 26), (2006, 6)), | |
(date(2006, 7, 25), (2006, 7)), | |
(date(2006, 8, 24), (2006, 7.5)), | |
(date(2006, 9, 22), (2006, 8)), | |
(date(2006, 10, 22), (2006, 9)), | |
(date(2006, 11, 21), (2006, 10)), | |
(date(2006, 12, 20), (2006, 11)), | |
], | |
2007: [ | |
(date(2006, 12, 20), (2006, 11)), | |
(date(2007, 1, 19), (2006, 12)), | |
(date(2007, 2, 18), (2007, 1)), | |
(date(2007, 3, 19), (2007, 2)), | |
(date(2007, 4, 17), (2007, 3)), | |
(date(2007, 5, 17), (2007, 4)), | |
(date(2007, 6, 15), (2007, 5)), | |
(date(2007, 7, 14), (2007, 6)), | |
(date(2007, 8, 13), (2007, 7)), | |
(date(2007, 9, 11), (2007, 8)), | |
(date(2007, 10, 11), (2007, 9)), | |
(date(2007, 11, 10), (2007, 10)), | |
(date(2007, 12, 10), (2007, 11)), | |
], | |
2008: [ | |
(date(2007, 12, 10), (2007, 11)), | |
(date(2008, 1, 8), (2007, 12)), | |
(date(2008, 2, 7), (2008, 1)), | |
(date(2008, 3, 8), (2008, 2)), | |
(date(2008, 4, 6), (2008, 3)), | |
(date(2008, 5, 5), (2008, 4)), | |
(date(2008, 6, 4), (2008, 5)), | |
(date(2008, 7, 3), (2008, 6)), | |
(date(2008, 8, 1), (2008, 7)), | |
(date(2008, 8, 31), (2008, 8)), | |
(date(2008, 9, 29), (2008, 9)), | |
(date(2008, 10, 29), (2008, 10)), | |
(date(2008, 11, 28), (2008, 11)), | |
(date(2008, 12, 27), (2008, 12)), | |
], | |
2009: [ | |
(date(2008, 12, 27), (2008, 12)), | |
(date(2009, 1, 26), (2009, 1)), | |
(date(2009, 2, 25), (2009, 2)), | |
(date(2009, 3, 27), (2009, 3)), | |
(date(2009, 4, 25), (2009, 4)), | |
(date(2009, 5, 24), (2009, 5)), | |
(date(2009, 6, 23), (2009, 5.5)), | |
(date(2009, 7, 22), (2009, 6)), | |
(date(2009, 8, 20), (2009, 7)), | |
(date(2009, 9, 19), (2009, 8)), | |
(date(2009, 10, 18), (2009, 9)), | |
(date(2009, 11, 17), (2009, 10)), | |
(date(2009, 12, 16), (2009, 11)), | |
], | |
2010: [ | |
(date(2009, 12, 16), (2009, 11)), | |
(date(2010, 1, 15), (2009, 12)), | |
(date(2010, 2, 14), (2010, 1)), | |
(date(2010, 3, 16), (2010, 2)), | |
(date(2010, 4, 14), (2010, 3)), | |
(date(2010, 5, 14), (2010, 4)), | |
(date(2010, 6, 12), (2010, 5)), | |
(date(2010, 7, 12), (2010, 6)), | |
(date(2010, 8, 10), (2010, 7)), | |
(date(2010, 9, 8), (2010, 8)), | |
(date(2010, 10, 8), (2010, 9)), | |
(date(2010, 11, 6), (2010, 10)), | |
(date(2010, 12, 6), (2010, 11)), | |
], | |
2011: [ | |
(date(2010, 12, 6), (2010, 11)), | |
(date(2011, 1, 4), (2010, 12)), | |
(date(2011, 2, 3), (2011, 1)), | |
(date(2011, 3, 5), (2011, 2)), | |
(date(2011, 4, 3), (2011, 3)), | |
(date(2011, 5, 3), (2011, 4)), | |
(date(2011, 6, 2), (2011, 5)), | |
(date(2011, 7, 1), (2011, 6)), | |
(date(2011, 7, 31), (2011, 7)), | |
(date(2011, 8, 29), (2011, 8)), | |
(date(2011, 9, 27), (2011, 9)), | |
(date(2011, 10, 27), (2011, 10)), | |
(date(2011, 11, 25), (2011, 11)), | |
(date(2011, 12, 25), (2011, 12)), | |
], | |
2012: [ | |
(date(2011, 12, 25), (2011, 12)), | |
(date(2012, 1, 23), (2012, 1)), | |
(date(2012, 2, 22), (2012, 2)), | |
(date(2012, 3, 22), (2012, 3)), | |
(date(2012, 4, 21), (2012, 3.5)), | |
(date(2012, 5, 21), (2012, 4)), | |
(date(2012, 6, 20), (2012, 5)), | |
(date(2012, 7, 19), (2012, 6)), | |
(date(2012, 8, 18), (2012, 7)), | |
(date(2012, 9, 16), (2012, 8)), | |
(date(2012, 10, 15), (2012, 9)), | |
(date(2012, 11, 14), (2012, 10)), | |
(date(2012, 12, 13), (2012, 11)), | |
], | |
2013: [ | |
(date(2012, 12, 13), (2012, 11)), | |
(date(2013, 1, 12), (2012, 12)), | |
(date(2013, 2, 10), (2013, 1)), | |
(date(2013, 3, 12), (2013, 2)), | |
(date(2013, 4, 10), (2013, 3)), | |
(date(2013, 5, 10), (2013, 4)), | |
(date(2013, 6, 9), (2013, 5)), | |
(date(2013, 7, 8), (2013, 6)), | |
(date(2013, 8, 7), (2013, 7)), | |
(date(2013, 9, 5), (2013, 8)), | |
(date(2013, 10, 5), (2013, 9)), | |
(date(2013, 11, 3), (2013, 10)), | |
(date(2013, 12, 3), (2013, 11)), | |
], | |
2014: [ | |
(date(2013, 12, 3), (2013, 11)), | |
(date(2014, 1, 1), (2013, 12)), | |
(date(2014, 1, 31), (2014, 1)), | |
(date(2014, 3, 1), (2014, 2)), | |
(date(2014, 3, 31), (2014, 3)), | |
(date(2014, 4, 29), (2014, 4)), | |
(date(2014, 5, 29), (2014, 5)), | |
(date(2014, 6, 27), (2014, 6)), | |
(date(2014, 7, 27), (2014, 7)), | |
(date(2014, 8, 25), (2014, 8)), | |
(date(2014, 9, 24), (2014, 9)), | |
(date(2014, 10, 24), (2014, 9.5)), | |
(date(2014, 11, 22), (2014, 10)), | |
(date(2014, 12, 22), (2014, 11)), | |
], | |
2015: [ | |
(date(2014, 12, 22), (2014, 11)), | |
(date(2015, 1, 20), (2014, 12)), | |
(date(2015, 2, 19), (2015, 1)), | |
(date(2015, 3, 20), (2015, 2)), | |
(date(2015, 4, 19), (2015, 3)), | |
(date(2015, 5, 18), (2015, 4)), | |
(date(2015, 6, 16), (2015, 5)), | |
(date(2015, 7, 16), (2015, 6)), | |
(date(2015, 8, 14), (2015, 7)), | |
(date(2015, 9, 13), (2015, 8)), | |
(date(2015, 10, 13), (2015, 9)), | |
(date(2015, 11, 12), (2015, 10)), | |
(date(2015, 12, 11), (2015, 11)), | |
], | |
2016: [ | |
(date(2015, 12, 11), (2015, 11)), | |
(date(2016, 1, 10), (2015, 12)), | |
(date(2016, 2, 8), (2016, 1)), | |
(date(2016, 3, 9), (2016, 2)), | |
(date(2016, 4, 7), (2016, 3)), | |
(date(2016, 5, 7), (2016, 4)), | |
(date(2016, 6, 5), (2016, 5)), | |
(date(2016, 7, 4), (2016, 6)), | |
(date(2016, 8, 3), (2016, 7)), | |
(date(2016, 9, 1), (2016, 8)), | |
(date(2016, 10, 1), (2016, 9)), | |
(date(2016, 10, 31), (2016, 10)), | |
(date(2016, 11, 29), (2016, 11)), | |
(date(2016, 12, 29), (2016, 12)), | |
], | |
2017: [ | |
(date(2016, 12, 29), (2016, 12)), | |
(date(2017, 1, 28), (2017, 1)), | |
(date(2017, 2, 26), (2017, 2)), | |
(date(2017, 3, 28), (2017, 3)), | |
(date(2017, 4, 26), (2017, 4)), | |
(date(2017, 5, 26), (2017, 5)), | |
(date(2017, 6, 24), (2017, 5.5)), | |
(date(2017, 7, 23), (2017, 6)), | |
(date(2017, 8, 22), (2017, 7)), | |
(date(2017, 9, 20), (2017, 8)), | |
(date(2017, 10, 20), (2017, 9)), | |
(date(2017, 11, 18), (2017, 10)), | |
(date(2017, 12, 18), (2017, 11)), | |
], | |
2018: [ | |
(date(2017, 12, 18), (2017, 11)), | |
(date(2018, 1, 17), (2017, 12)), | |
(date(2018, 2, 16), (2018, 1)), | |
(date(2018, 3, 17), (2018, 2)), | |
(date(2018, 4, 16), (2018, 3)), | |
(date(2018, 5, 15), (2018, 4)), | |
(date(2018, 6, 14), (2018, 5)), | |
(date(2018, 7, 13), (2018, 6)), | |
(date(2018, 8, 11), (2018, 7)), | |
(date(2018, 9, 10), (2018, 8)), | |
(date(2018, 10, 9), (2018, 9)), | |
(date(2018, 11, 8), (2018, 10)), | |
(date(2018, 12, 7), (2018, 11)), | |
], | |
2019: [ | |
(date(2018, 12, 7), (2018, 11)), | |
(date(2019, 1, 6), (2018, 12)), | |
(date(2019, 2, 5), (2019, 1)), | |
(date(2019, 3, 7), (2019, 2)), | |
(date(2019, 4, 5), (2019, 3)), | |
(date(2019, 5, 5), (2019, 4)), | |
(date(2019, 6, 3), (2019, 5)), | |
(date(2019, 7, 3), (2019, 6)), | |
(date(2019, 8, 1), (2019, 7)), | |
(date(2019, 8, 30), (2019, 8)), | |
(date(2019, 9, 29), (2019, 9)), | |
(date(2019, 10, 28), (2019, 10)), | |
(date(2019, 11, 27), (2019, 11)), | |
(date(2019, 12, 26), (2019, 12)), | |
], | |
2020: [ | |
(date(2019, 12, 26), (2019, 12)), | |
(date(2020, 1, 25), (2020, 1)), | |
(date(2020, 2, 24), (2020, 2)), | |
(date(2020, 3, 24), (2020, 3)), | |
(date(2020, 4, 23), (2020, 4)), | |
(date(2020, 5, 23), (2020, 4.5)), | |
(date(2020, 6, 21), (2020, 5)), | |
(date(2020, 7, 21), (2020, 6)), | |
(date(2020, 8, 19), (2020, 7)), | |
(date(2020, 9, 17), (2020, 8)), | |
(date(2020, 10, 17), (2020, 9)), | |
(date(2020, 11, 15), (2020, 10)), | |
(date(2020, 12, 15), (2020, 11)), | |
], | |
2021: [ | |
(date(2020, 12, 15), (2020, 11)), | |
(date(2021, 1, 13), (2020, 12)), | |
(date(2021, 2, 12), (2021, 1)), | |
(date(2021, 3, 13), (2021, 2)), | |
(date(2021, 4, 12), (2021, 3)), | |
(date(2021, 5, 12), (2021, 4)), | |
(date(2021, 6, 10), (2021, 5)), | |
(date(2021, 7, 10), (2021, 6)), | |
(date(2021, 8, 8), (2021, 7)), | |
(date(2021, 9, 7), (2021, 8)), | |
(date(2021, 10, 6), (2021, 9)), | |
(date(2021, 11, 5), (2021, 10)), | |
(date(2021, 12, 4), (2021, 11)), | |
], | |
2022: [ | |
(date(2021, 12, 4), (2021, 11)), | |
(date(2022, 1, 3), (2021, 12)), | |
(date(2022, 2, 1), (2022, 1)), | |
(date(2022, 3, 3), (2022, 2)), | |
(date(2022, 4, 1), (2022, 3)), | |
(date(2022, 5, 1), (2022, 4)), | |
(date(2022, 5, 30), (2022, 5)), | |
(date(2022, 6, 29), (2022, 6)), | |
(date(2022, 7, 29), (2022, 7)), | |
(date(2022, 8, 27), (2022, 8)), | |
(date(2022, 9, 26), (2022, 9)), | |
(date(2022, 10, 25), (2022, 10)), | |
(date(2022, 11, 24), (2022, 11)), | |
(date(2022, 12, 23), (2022, 12)), | |
], | |
2023: [ | |
(date(2022, 12, 23), (2022, 12)), | |
(date(2023, 1, 22), (2023, 1)), | |
(date(2023, 2, 20), (2023, 2)), | |
(date(2023, 3, 22), (2023, 2.5)), | |
(date(2023, 4, 20), (2023, 3)), | |
(date(2023, 5, 20), (2023, 4)), | |
(date(2023, 6, 18), (2023, 5)), | |
(date(2023, 7, 18), (2023, 6)), | |
(date(2023, 8, 16), (2023, 7)), | |
(date(2023, 9, 15), (2023, 8)), | |
(date(2023, 10, 15), (2023, 9)), | |
(date(2023, 11, 13), (2023, 10)), | |
(date(2023, 12, 13), (2023, 11)), | |
], | |
2024: [ | |
(date(2023, 12, 13), (2023, 11)), | |
(date(2024, 1, 11), (2024, 12)), | |
(date(2024, 2, 10), (2024, 1)), | |
(date(2024, 3, 10), (2024, 2)), | |
(date(2024, 4, 9), (2024, 3)), | |
(date(2024, 5, 8), (2024, 4)), | |
(date(2024, 6, 6), (2024, 5)), | |
(date(2024, 7, 6), (2024, 6)), | |
(date(2024, 8, 4), (2024, 7)), | |
(date(2024, 9, 3), (2024, 8)), | |
(date(2024, 10, 3), (2024, 9)), | |
(date(2024, 11, 1), (2024, 10)), | |
(date(2024, 12, 1), (2024, 11)), | |
(date(2024, 12, 31), (2024, 12)), | |
], | |
2025: [ | |
(date(2024, 12, 31), (2024, 12)), | |
(date(2025, 1, 29), (2025, 1)), | |
(date(2025, 2, 28), (2025, 2)), | |
(date(2025, 3, 29), (2025, 3)), | |
(date(2025, 4, 28), (2025, 4)), | |
(date(2025, 5, 27), (2025, 5)), | |
(date(2025, 6, 25), (2025, 6)), | |
(date(2025, 7, 25), (2025, 6.5)), | |
(date(2025, 8, 23), (2025, 7)), | |
(date(2025, 9, 22), (2025, 8)), | |
(date(2025, 10, 21), (2025, 9)), | |
(date(2025, 11, 20), (2025, 10)), | |
(date(2025, 12, 20), (2025, 11)), | |
], | |
2026: [ | |
(date(2025, 12, 20), (2025, 11)), | |
(date(2026, 1, 19), (2025, 12)), | |
(date(2026, 2, 17), (2026, 1)), | |
(date(2026, 3, 19), (2026, 2)), | |
(date(2026, 4, 17), (2026, 3)), | |
(date(2026, 5, 17), (2026, 4)), | |
(date(2026, 6, 15), (2026, 5)), | |
(date(2026, 7, 14), (2026, 6)), | |
(date(2026, 8, 13), (2026, 7)), | |
(date(2026, 9, 11), (2026, 8)), | |
(date(2026, 10, 11), (2026, 9)), | |
(date(2026, 11, 9), (2026, 10)), | |
(date(2026, 12, 9), (2026, 11)), | |
], | |
2027: [ | |
(date(2026, 12, 9), (2026, 11)), | |
(date(2027, 1, 8), (2026, 12)), | |
(date(2027, 2, 7), (2027, 1)), | |
(date(2027, 3, 8), (2027, 2)), | |
(date(2027, 4, 7), (2027, 3)), | |
(date(2027, 5, 6), (2027, 4)), | |
(date(2027, 6, 5), (2027, 5)), | |
(date(2027, 7, 4), (2027, 6)), | |
(date(2027, 8, 2), (2027, 7)), | |
(date(2027, 9, 1), (2027, 8)), | |
(date(2027, 9, 30), (2027, 9)), | |
(date(2027, 10, 29), (2027, 10)), | |
(date(2027, 11, 28), (2027, 11)), | |
(date(2027, 12, 28), (2027, 12)), | |
], | |
2028: [ | |
(date(2027, 12, 28), (2027, 12)), | |
(date(2028, 1, 27), (2028, 1)), | |
(date(2028, 2, 25), (2028, 2)), | |
(date(2028, 3, 26), (2028, 3)), | |
(date(2028, 4, 25), (2028, 4)), | |
(date(2028, 5, 24), (2028, 5)), | |
(date(2028, 6, 23), (2028, 5.5)), | |
(date(2028, 7, 22), (2028, 6)), | |
(date(2028, 8, 20), (2028, 7)), | |
(date(2028, 9, 19), (2028, 8)), | |
(date(2028, 10, 18), (2028, 9)), | |
(date(2028, 11, 16), (2028, 10)), | |
(date(2028, 12, 16), (2028, 11)), | |
], | |
2029: [ | |
(date(2028, 12, 16), (2028, 11)), | |
(date(2029, 1, 15), (2028, 12)), | |
(date(2029, 2, 13), (2029, 1)), | |
(date(2029, 3, 15), (2029, 2)), | |
(date(2029, 4, 14), (2029, 3)), | |
(date(2029, 5, 13), (2029, 4)), | |
(date(2029, 6, 12), (2029, 5)), | |
(date(2029, 7, 12), (2029, 6)), | |
(date(2029, 8, 10), (2029, 7)), | |
(date(2029, 9, 8), (2029, 8)), | |
(date(2029, 10, 8), (2029, 9)), | |
(date(2029, 11, 6), (2029, 10)), | |
(date(2029, 12, 5), (2029, 11)), | |
], | |
2030: [ | |
(date(2029, 12, 5), (2029, 11)), | |
(date(2030, 1, 4), (2029, 12)), | |
(date(2030, 2, 3), (2030, 1)), | |
(date(2030, 3, 4), (2030, 2)), | |
(date(2030, 4, 3), (2030, 3)), | |
(date(2030, 5, 2), (2030, 4)), | |
(date(2030, 6, 1), (2030, 5)), | |
(date(2030, 7, 1), (2030, 6)), | |
(date(2030, 7, 30), (2030, 7)), | |
(date(2030, 8, 29), (2030, 8)), | |
(date(2030, 9, 27), (2030, 9)), | |
(date(2030, 10, 27), (2030, 10)), | |
(date(2030, 11, 25), (2030, 11)), | |
(date(2030, 12, 25), (2030, 12)), | |
], | |
} | |
def generate_rokuyo(_from, to=None): | |
''' 指定期間の六曜を取得 | |
''' | |
retval = [] | |
if to is None: | |
to = _from | |
datedelta = to - _from | |
i = 0 | |
tsuitachi = None | |
lastyear = None | |
tsuitachi_idx = None | |
while i <= datedelta.days: | |
# 日にちループ | |
current = _from + timedelta(i) | |
if lastyear != current.year: | |
# 年が変わるとき | |
tsuitachi = OLD_MONTH_TSUITACHI_TABLE.get(current.year) | |
if tsuitachi is None: | |
retval.append(None) | |
i += 1 | |
continue | |
lastyear = current.year | |
tsuitachi_idx = 1 | |
olddate = None | |
while tsuitachi_idx < len(tsuitachi): | |
# 旧暦の月を計算 | |
if current < tsuitachi[tsuitachi_idx][0]: | |
olddate = tsuitachi[tsuitachi_idx - 1] | |
break | |
tsuitachi_idx += 1 | |
if olddate is None: | |
olddate = tsuitachi[len(tsuitachi) - 1] | |
datediff = (current - olddate[0]).days | |
retval.append((ROKUYO_MONTH[int(olddate[1][1]) - 1] + datediff) % 6) | |
i += 1 | |
return retval |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment