[How-to] - How to convert string to pendulum #651
-
Hello beautiful people! I have for hours and hours trying to figure out how to use pendulum in a case which is super hard. I have a text that returns
which means: Closing in : 1 day, 6 hours, 8 minutes and 45 seconds. and I want to be able to convert this into pendulum.format/parse (so I have something like 2022-09-01 12:00:00)
which returns |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @BarryAljawari - I think you need to make your question more clear. You are creating a pendulum.Duration object (something that represents a length of time), yet you want to display a format that only makes sense for a pendulum.Datetime object (something that designates a particular moment in time). If you want to explore different ways of turning a duration into a string, have a look at the docs about them: https://pendulum.eustace.io/docs/#properties-and-duration-methods . If you want to convert the Duration into a DateTime, you have to realize that doesn't make sense without more context. That's like saying, I'm going to wait for 4 hours and 52 minutes; express that as a calendar year, month, date, hour and minute. |
Beta Was this translation helpful? Give feedback.
Hi @BarryAljawari - I think you need to make your question more clear. You are creating a pendulum.Duration object (something that represents a length of time), yet you want to display a format that only makes sense for a pendulum.Datetime object (something that designates a particular moment in time).
If you want to explore different ways of turning a duration into a string, have a look at the docs about them: https://pendulum.eustace.io/docs/#properties-and-duration-methods . If you want to convert the Duration into a DateTime, you have to realize that doesn't make sense without more context. That's like saying, I'm going to wait for 4 hours and 52 minutes; express that as a calendar ye…