It's a python library. It solves complex time operations. It is suitable for the concepts of tomorrow and yesterday. I have a lot of history problems in my projects. With this package, the history problem is solved very simply.
Do take forward and back dates
Simply set the date according to countries
Format the date
Parse
Doing weekly jobs
Understand future and past concepts
It is a package for the Python language. Time solves your problem. It deals with complicated history problems. It can be treated as a boolean expression. There is a wide time zone support. Writing and meaning is easy. There is extensive python support.
Very easy
pip install pendulum
its done!
| ID | Method | Description |
|---|---|---|
| 1 | pendulum | Base class. Everything goes through it. |
| 2 | pendulum.create() | Creates a date with the information provided. |
| 3 | pendulum.now() | It creates the current date. |
| 4 | .tomorrow() | It creates the date of tomorrow. |
| 5 | .yesterday() | It creates the date of yesterday. |
| 6 | .tomorrow('Europe/London') | Time zone can be customized. |
| 7 | .from_format(time, format, tz) | Can be created with custom formats. |
| 8 | .to_datetime_string() | Returns the date as a string |
| 9 | .add(hours=-1) | It shows 1 hour back. |
| 10 | .add(days=1) | It shows 1 day nex. |
| 11 | .diff(dt2) | Finds the difference between two dates. |
| 12 | .parse('1994-03-16 22:00:00') | parse to datetime format |
| 13 | .parse('1994-03-16 22:00:00', tz='Europe/London') | Time zone can be customized. |
| 14 | .is_future() | Is the future a date? |
| 15 | .is_past() | Is the past a date? |
| 16 | .is_weekday() | Is the date in the weekday? |
| 17 | .is_weekend() | Is the date in the weekend? |
These methods generally solve many problems. But is has more detail. Now let's use the above methods. I will describe a list by number.
You have time zone control. Do not parameterize the method almost does the same operation. (create | now)
pendulum.create()
# <Pendulum 2018-02-19T00:00:00 00:00>
pendulum.now()
# <Pendulum 2018-02-19T23:42:15.660781 03:00>
pendulum.create(2015, 1, 31, 0)
#<Pendulum 2015-01-31T00:00:00 00:00>
pendulum.create(2015, 3, 2, tz='America/Toronto')
#<Pendulum 2015-03-02T00:00:00-05:00>
date = pendulum.now()
#<Pendulum 2018-02-19T23:43:35.998675 03:00>
date.tomorrow()
#<Pendulum 2018-02-20T00:00:00 03:00>
date.yesterday()
#<Pendulum 2018-02-18T00:00:00 03:00>
date.tomorrow('Europe/London')
#<Pendulum 2018-02-20T00:00:00 00:00>
date = pendulum.now()
#<Pendulum 2018-02-19T23:52:46.187968 03:00>
date.to_datetime_string()
#'2018-02-19 23:52:46'
date.add(hours=-1)
#<Pendulum 2018-02-19T22:52:46.187968 03:00>
date.add(days=1)
#<Pendulum 2018-02-20T23:52:46.187968 03:00>
I think it's a simple and useful library to use. I am currently using this library in my new project. I had a lot of problems with time. This package made me speed up. I want to write in this regard.
If you have a question that you are wondering, you can ask me.