arrow icon indicating copy to clipboard operation
arrow copied to clipboard

force exact match on .get()

Open jhonnattan123 opened this issue 3 years ago • 3 comments

Issue Description

when executing the following statement:

import arrow
arrow.get('95-03-10 23:01:44','YY-M-D HH:mm:ss')
<Arrow [1995-03-10T23:01:44+00:00]>

the library returns me the date, but I gave it a single M, so it shouldn't have done the .get() but it did. one would expect it to fail, as the correct format should be 'YY-MM-D HH:mm:ss' for that same example.

I would like to know if this is a bug or is there a parameter to force the match to be exact?

System Info

  • 🖥 ubuntu 18.04 32 bits
  • 🐍 Python 3.8.5
  • 🏹 1.2.1

jhonnattan123 avatar Jan 13 '22 19:01 jhonnattan123

Hi @jhonnattan123 this is a bug with the M and MM tokens, we will look into fixing it.

systemcatch avatar Jan 19 '22 16:01 systemcatch

Hey there,

I have checked the supported tokens in the documentation. The token M seems to be valid, so

>>> arrow.get('95-03-10 23:01:44','YY-M-D HH:mm:ss')

should not fail, but instead return (no leading zero in front of month):

<Arrow [1995-3-10T23:01:44+00:00]>

Is this conclusion correct?

ALee008 avatar Jun 09 '22 08:06 ALee008

Hey @ALee008 not quite.

I think you are confusing formatting where this M would be valid. Arrow objects always store the month in zero padded form internally.

systemcatch avatar Jun 10 '22 11:06 systemcatch