<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55036>55036</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            get_date return value for parse failures does not match libstdc++ or MSVC STL
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          DavidSpickett
      </td>
    </tr>
</table>

<pre>
    In this example [get_date_test.txt](https://github.com/llvm/llvm-project/files/8540373/get_date_test.txt), libc++, libstdc++ and MSVC STL all have different return values from `get_date`. I think libstdc++ has it right, not 100% sure.

godbolt for libstdc++ and MSVC STL: https://godbolt.org/z/1Mocbv4zn

Expected behaviour:
Returns: An iterator pointing immediately beyond the last character recognized as possibly part of a valid date[.](http://eel.is/c++draft/locale.time.get.virtuals#6.sentence-1)

I think this is done to support a use case where you try to parse a date and it fails, so you want to know/show where and why. By printing the rest of the date using the return value, you can say "everything before this was fine, we failed here".

libstdc++:
```
Parse failed.
ret == end of stream? 0
Unparsed string: 0/01/2013
Characters copied: 9
Parse failed.
ret == end of stream? 0
Unparsed string: 3/01/2013
Characters copied: 9
```

This makes sense because the "1" in "13/01/2013" could have possibly been part of a valid date, until you saw the "3". Same with the "00" case, leading zero is allowed so it could possibly have been part of a valid date, the second zero not.

MSVC STL:
```
Parse failed.
ret == end of stream? 1
Unparsed string: 
Characters copied: 0
Parse failed.
ret == end of stream? 1
Unparsed string: 
Characters copied: 0
```

This could be more on the lines of saying a date with an invalid field makes every other character in the date invalid. Though if the standard wanted that I assume it would say so, the "possibly part of" makes me think this approach is incorrect. At the very least the feedback is completely binary.

libc++:
```
Parse failed.
ret == end of stream? 0
Unparsed string: /01/2013
Characters copied: 8
Parse failed.
ret == end of stream? 0
Unparsed string: /01/2013
Characters copied: 8
```

Similair to the libstdc++ case but we consume both month characters. Which doesn't make much sense to the user because we're basically saying the "13" and "00" were valid and that something is wrong in the day field.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFVl1v2zYU_TXyy0UFW7Kd-MEP-ViAAiswLN32WFDilcVFIgWSsuL8-h1SsmNnbbACRQfIsijxfp17eMjCyMP2oyZfK0f8LNquYUpWtzv2X6Tw_MWz86l_9snqPsmua-87l-Q3SfaAa6d83RdpaVoMmmZ__PvQWfM3lx7DSjXs8H-9Ws7zqzwY_ctztkmyO2pUUSbZbbziyHk5vSChJX16_POOHj__SqJpqBZ7Jqmqii1rT5Z9bzXtRdOzo8qalpL1_BgJjyl9DCXqpzeOa-FIwV7tah_CauNpMZ8n2YpcbzlN5vfJ_Ga874wsTOOpMvad9AAOvUFptEuN3WH0gt_ikymL_fJFn7v_5bkDZCypYFSnTG-Dh_jp91he8Eg3GvmyFR5JdEZpr_SOVNuyVKi0OcD6YJCOr5ka4TyVtbACfi1AKs1OqxeEQNWdcU4VMOiE9WQqEgE-JSkitrpNXxt-qoS5SVXo5lS4tKIKTW5MKRpOvWo5BejpXlnfiwYz83Xq0CDWJX9YhEafFXzsSKQeLmk0kzcAvusMchLUO6ZS4DbU6DMdTE_eHsIcJI3XIiYb4UcTK6FCyDtyJk4dBJiBuU_aDEjS1WaYHAWDoT6kdIvy7QRiQMyCkgGL8Bxd9-710yvFQpAQoRSanDhQkmW8Z3sI9ezQATCEx7IGIF0pHS0GjikC_pAEbC7YdcGoU-dB3emKw99i2aOXyRp5UZLf4yJGWUjeecuiTfIHmqz-0BEuGb4gwUAjMPxhjoY8ZPNFPs66OxLFUWk6xTLM2_zguPn3xX1T_nj_HIBtxRNWOriFvAouRaBKaBNghfuMlI6Pl_HwvjR9I0f5OK2Agll_fRmgaz3Y0cRuOzEcQwRXKT2KFtSEBh5fB-HIImOjhLGQgQ8vbE3gN3TLDAENE9g6JnLKIWb0biIhhsMSBtjRI6TqgkBnAvQjuLP4Zg_fadvPD_VthowAF0xtWI1Gj5KItehidHEIvZkUJDYR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