Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b451a83
Add C implementation of date.fromisoformat
pganssle Dec 1, 2017
4ccef0a
Add python implementation of date.fromisoformat
pganssle Dec 1, 2017
13e8e48
Add tests for date.fromisoformat
pganssle Dec 1, 2017
6fa5c55
Implement C version of datetime.fromisoformat
pganssle Dec 2, 2017
0d44220
Add initial test suite for C-only datetime.fromisoformat
pganssle Dec 2, 2017
327d0fc
Add C implementation of time.fromisoformat()
pganssle Dec 4, 2017
52b2175
Add tests for time.isoformat()
pganssle Dec 4, 2017
f1b78af
Add pure python implementation of time.fromisoformat()
pganssle Dec 4, 2017
aeaa9ca
Add tests for pure python time.fromisoformat()
pganssle Dec 4, 2017
094ccf4
Add pure python implementation of datetime.fromisoformat
pganssle Dec 4, 2017
2a8120d
Enable tests for pure python datetime.fromisoformat
pganssle Dec 4, 2017
af9e6d0
Add documentation for [date][time].fromisoformat()
pganssle Dec 4, 2017
cf802af
Consolidate helper functions into parse_digits
pganssle Dec 5, 2017
626d239
Refactor datetime.isoformat round trip tests
pganssle Dec 5, 2017
7c771e7
Refactor C code for PEP 7
pganssle Dec 5, 2017
8fbd752
Add support for seconds in fromisoformat offsets
pganssle Dec 6, 2017
4d55e05
Fix pure python implementation of isoformat() for sub-second zones
pganssle Dec 9, 2017
5a233fb
Add support for subsecond offsets to fromisoformat
pganssle Dec 9, 2017
9fa91db
Fix documentation and pure python error catching in fromisoformat
pganssle Dec 18, 2017
ffdb2af
Drop unsupported sep parameter in _tzstr
pganssle Dec 18, 2017
18a5fa8
Add test for ambiguous isoformat strings
pganssle Dec 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Consolidate helper functions into parse_digits
  • Loading branch information
pganssle committed Dec 10, 2017
commit cf802aff7492781714eb2b83854dfe79ccf71561
15 changes: 3 additions & 12 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,22 +666,13 @@ set_date_fields(PyDateTime_Date *self, int y, int m, int d)
/* ---------------------------------------------------------------------------
* String parsing utilities and helper functions
*/
static inline unsigned int to_int(char ptr)
{
return (unsigned int)(ptr - '0');
}

static inline int is_digit(unsigned int tmp)
{
return tmp <= 9;
}

static inline const char* parse_digits(const char* ptr, int* var,
static const char* parse_digits(const char* ptr, int* var,
size_t num_digits)
{
for (size_t i = 0; i < num_digits; ++i) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C99 - style for loops are not specifically mentioned in the "C dialect" section of PEP 7. I personally like this style, so if this compiles without warnings, we may leave it.

int tmp = to_int(*(ptr++));
if (!is_digit(tmp)) { return NULL; }
unsigned int tmp = (unsigned int)(*(ptr++) - '0');
if (tmp > 9) { return NULL; }
*var *= 10;
*var += (signed int)tmp;
}
Expand Down