You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Initialize from existing datetime.date object? #250
pendulum.instance(dt) works for datetime.datetime, but how can I initialize a Pendulum object from an existing datetime.date (specifically a Django DateField)?
Could we add that behavior to pendulum.instance()?
Reacted by Philipp Grosswiler, Nicolas Beuchat, Doug Mitarotonda, Georg Perhofer, Swen Wenzel, Prateek Pisat, jacobg, Nathaniel Brown, Cédric, Marcin Milewski and 12 more
This is a no-brainer for me. I work with an ORM that returns datetime.date instances, and having to pick them apart to pass them into pendulum.instance feels like the symptom of a missing feature.
I have created a first draft at https://github.com/kakulukia/pendulum .. im missing some tests before opening a puss request, but like to get some feedback first.
I've also looked into the documentation & the code in search for this behavior. In the code, I see that even the shorthand class functions to initialize a Date like today first construct a native datetime.date object before they create the instance using its result. This surely would also profit from a Date.instance class function constructor.
Activity
jacebrowning commentedon Jul 21, 2018
Could we add that behavior to
pendulum.instance()?kakulukia commentedon Aug 31, 2018
+1
trancee commentedon Sep 4, 2018
+1
I would also check for
datetime.timeso we have all possible cases of a datetime covered with Pendulum.joaodlf commentedon Dec 12, 2018
+1 This would be a great addition to the API!
SemMulder commentedon May 6, 2019
+1
joaomcarlos commentedon Sep 27, 2019
+1
racerthunder commentedon Mar 17, 2020
+1
lonsun commentedon Jun 26, 2020
+1
Alsanis commentedon Jul 6, 2020
+1
rodrigondec commentedon Sep 16, 2020
+1
madisvain commentedon Apr 27, 2021
I would like to pump this. I find doing this over and over and would love if pendulum had this feature built in.
AaronBeaudoin commentedon Nov 16, 2021
This is a no-brainer for me. I work with an ORM that returns
datetime.dateinstances, and having to pick them apart to pass them intopendulum.instancefeels like the symptom of a missing feature.richieadler commentedon Jan 28, 2022
+1
kakulukia commentedon Mar 1, 2022
I have created a first draft at https://github.com/kakulukia/pendulum .. im missing some tests before opening a puss request, but like to get some feedback first.
blondelg commentedon Dec 30, 2022
+1
yardensachs commentedon May 3, 2023
+1
lena commentedon May 3, 2023
+1
mcguigon0033 commentedon May 3, 2023
+1
jackb2113 commentedon May 3, 2023
+1
codytowstik commentedon May 8, 2023
+1 !
FichteFoll commentedon Jul 3, 2023
I've also looked into the documentation & the code in search for this behavior. In the code, I see that even the shorthand class functions to initialize a
Dateliketodayfirst construct a nativedatetime.dateobject before they create the instance using its result. This surely would also profit from aDate.instanceclass function constructor.https://github.com/sdispater/pendulum/blob/c4e518c950bcf0a4214b36c5992ae27d3c40e47f/pendulum/date.py#L740-L755