Python pendulum Parsing 1














































Python pendulum Parsing 1



Parse String to Date Time



 Parse() function is used to parse a string having commonly used formats to DateTime object. If you   want to pass a non-standard or more complicated string, then use the from_format() function.

 However, if you want the library to fall back on the dateutil parser, you have to pass strict=False.

 The library natively supports the RFC 3339 format, most ISO 8601 formats and some other common formats.Like below


RFC 3339

STRINGOUTPUT
1996-12-19T16:39:57-08:001996-12-19T16:39:57-08:00
1990-12-31T23:59:59Z1990-12-31T23:59:59+00:00

ISO 8601

Datetime

STRINGOUTPUT
20161001T143028+05302016-10-01T14:30:28+05:30
20161001T142016-10-01T14:00:00+00:00

Date

STRINGOUTPUT
20122012-01-01T00:00:00+00:00
2012-05-032012-05-03T00:00:00+00:00
201205032012-05-03T00:00:00+00:00
2012-052012-05-01T00:00:00+00:00

Ordinal day

STRINGOUTPUT
2012-0072012-01-07T00:00:00+00:00
20120072012-01-07T00:00:00+00:00

Week number

STRINGOUTPUT
2012-W052012-01-30T00:00:00+00:00
2012W052012-01-30T00:00:00+00:00
2012-W05-52012-02-03T00:00:00+00:00
2012W0552012-02-03T00:00:00+00:00

Time

When passing only time information the date will default to today.

STRINGOUTPUT
00:002016-12-17T00:00:00+00:00
12:04:232016-12-17T12:04:23+00:00
1204232016-12-17T12:04:23+00:00
12:04:23.452016-12-17T12:04:23.450000+00:00

Intervals

STRINGOUTPUT
2007-03-01T13:00:00Z/2008-05-11T15:30:00Z2007-03-01T13:00:00+00:00 -> 2008-05-11T15:30:00+00:00
2008-05-11T15:30:00Z/P1Y2M10DT2H30M2008-05-11T15:30:00+00:00 -> 2009-07-21T18:00:00+00:00
P1Y2M10DT2H30M/2008-05-11T15:30:00Z2007-03-01T13:00:00+00:00 -> 2008-05-11T15:30:00+00:00




More Articles of Anmol Agrawal:

Name Views Likes
Python Pendulum Why to use Pendulum 176 0
Python Pendulum Limitations in DJANGO 262 0
Python Pendulum Limitations in MYSQLCLIENT 182 0
Python Pendulum Limitations in SQLITE3 197 0
Python Pendulum Testing 2 182 0
Python Pendulum Testing 215 0
Python Pendulum Range 220 0
Python Pendulum Period 3 185 0
Python Pendulum Period 2 184 0
Python Pendulum Period 187 0
Python Pendulum Properties and Duration Methods 2 185 0
Python Pendulum Properties and Duration Methods 187 0
Python Pendulum Instantiation 185 0
Python Pendulum Duration 169 0
Python Pendulum TImezone usage 2 180 0
Python Pendulum Timezone usage 191 0
Python Pendulum Switching Timezones 177 0
Python Pendulum Shifting Time to Transition 207 0
Python Pendulum Normalization 192 0
Python Pendulum Modifiers 2 191 0
Python Pendulum Modifiers 190 0
Python Pendulum Difference for Humans 2 211 0
Python Pendulum Difference for Humans 230 0
Python Pendulum Difference 265 0
Python pendulum Substraction 209 0
Pyhton pendulum Addition 215 0
Python pendulum Comapaison part 2 209 0
Python Pendulum Comparison 217 0
Python Pendulum Localized Formats and Escaping characteristics 196 0
Python pendulum Tokens 198 0
Python pendulum Formatter 208 0
Python pendulum Common Formats 201 0
Python pendulum String Formatting 217 0
Python pendulum Fluent helpers 2 185 0
Python pendulum Fluent helpers 186 0
Python pendulum Attributes and Properties 218 0
Python pendulum Localization 230 118
Python pendulum parsing 2 221 23
Python pendulum Parsing 1 230 61
Python pendulum 2 247 57
Python pendulum basics 220 9
python library Pendulum 220 33
python winsound.SND_PURGE and winsound.SND_WAIT 263 5
Python winsound.SND_NOSTOP 276 1
Python winsound.SND_NODEFAULT 234 1
python winsound.SND_ASYNC not excecuting problem 244 2
Python winsound functions 295 3
python winsound.SND_ALIAS 286 1
Python winsound.MessageBeep() 449 1
Python winsound basic introduction 409 1

Comments