Skip to content

Instantly share code, notes, and snippets.

@dogrunjp
Last active April 3, 2017 09:05
Show Gist options
  • Save dogrunjp/7b7438f94df47f8bcdb8e967cbf8e542 to your computer and use it in GitHub Desktop.
Save dogrunjp/7b7438f94df47f8bcdb8e967cbf8e542 to your computer and use it in GitHub Desktop.
もしかしたら、今日の正しい日付を知りたいという需要があるかもしれないという気持ちから、Python-fireで正しい今日の日付を所得するスクリプトを書いてみました。日々の精進が大切ですね。 pip install fire が必用。 $ python march.py day で本来今日は何日なのか知る事ができます。
from datetime import datetime
import fire
dfm = '%Y/%m/%d'
today = datetime.today()
basedate = datetime.strptime("2017/03/31", dfm)
class March(object):
def day(self, td=today):
delta = td - basedate
d = int(str(delta).split(" ")[0])
real_day = 31 + d
real_date = "2017/03/" + str(real_day)
print(real_date)
if __name__ == '__main__':
fire.Fire(March)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment