项目作者: dxillar

项目描述 :
Highly motivated package from Python's core datetime package, which operates on Bikram Sambat Date and Nepal Time.
高级语言: Python
项目地址: git://github.com/dxillar/nepali-datetime.git
创建时间: 2019-01-07T11:26:05Z
项目社区:https://github.com/dxillar/nepali-datetime

开源协议:MIT License

下载


Nepali Datetime (Bikram Sambat Date & Nepal Time)

The package inspired from Python’s core datetime package that
operates on top of Bikram Sambat (B.S) Date & Nepal Time (NPT) +05:45.

Supports: Python 3.5+

Basic Usage

  1. # importing
  2. >>> import datetime
  3. >>> import nepali_datetime
  4. # today's date
  5. >>> datetime.date.today()
  6. >>> nepali_datetime.date.today()
  7. # now datetime
  8. >>> datetime.datetime.now()
  9. >>> nepali_datetime.datetime.now()
  10. # creating date object
  11. >>> datetime.date(2020, 9, 4)
  12. >>> nepali_datetime.date(2077, 5, 19)
  13. # creating datetime object
  14. >>> datetime.datetime(2020, 9, 4, 8, 26, 10, 123456)
  15. >>> nepali_datetime.datetime(2077, 5, 19, 8, 26, 10, 123456)
  16. # date/datetime formatting
  17. >>> nepali_datetime.datetime(2077, 5, 19, 8, 26, 10, 123456).strftime("%d %B %Y")
  18. # 19 Bhadau 2077
  19. # datetime parsed from string (strptime)
  20. >>> nepali_datetime.datetime.strptime('2077-09-12', '%Y-%m-%d')
  21. # nepali_datetime.datetime(2077, 9, 12, 0, 0)
  22. # date/datetime formatting with Nepali unicode support
  23. >>> nepali_datetime.date(1977, 10, 25).strftime('%K-%n-%D (%k %N %G)')
  24. # १९७७-१०-२५ (७७ माघ आइतबार)
  25. # datetime.timedelta addition/subtraction
  26. >>> nepali_datetime.date(1990, 5, 10) + datetime.timedelta(days=350)
  27. # nepali_datetime.date(1991, 4, 26)
  28. >>> nepali_datetime.datetime(1990, 5, 10, 5, 10, 20) + datetime.timedelta(hours=3, minutes=15)
  29. # nepali_datetime.date(1990, 5, 10, 8, 25, 20)
  30. # convert B.S to A.D date and vice-versa
  31. >>> nepali_datetime.date(1999, 7, 25).to_datetime_date()
  32. # datetime.date(1942, 11, 10)
  33. >>> nepali_datetime.date.from_datetime_date(datetime.date(1942, 11, 10))
  34. # nepali_datetime.date(1999, 7, 25)
  35. # Bikram Sambat monthly calendar
  36. >>> nepali_datetime.date(2078, 1, 1).calendar()
  37. Baishakh 2078
  38. Sun Mon Tue Wed Thu Fri Sat
  39. 1 2 3 4
  40. 5 6 7 8 9 10 11
  41. 12 13 14 15 16 17 18
  42. 19 20 21 22 23 24 25
  43. 26 27 28 29 30 31

Installation

  1. $ pip install nepali-datetime

Documentation

Complete usage documentations can be found here.

Contribution

Any contributions are most welcome. Do check this guidelines CONTRIBUTING.md for code contribution.