dateparser2 4.0.1

Library for parsing randomly formatted date strings


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Date Parser 2 (dateparser2) made @safe

A port of the Python Dateutil date parser. This module offers a generic date/time string parser which is able to parse most known formats to represent a date and/or time. This module attempts to be forgiving with regards to unlikely input formats, returning a SysTime object even for dates which are ambiguous.

Simple Example

View the docs for more.

import std.datetime;
import dateparser2;

void main()
{
    assert(parse("2003-09-25") == SysTime(DateTime(2003, 9, 25)));
    assert(parse("09/25/2003") == SysTime(DateTime(2003, 9, 25)));
    assert(parse("Sep 2003")   == SysTime(DateTime(2003, 9, 1)));
}

Install With Dub

{
    ...
    "dependencies": {
        "dateparser2": "~>4.0.0"
    }
}

Speed

Based on master, measured on a 2015 Macbook Pro 2.8GHz Intel i7. Python times measured with ipython's %timeit function. D times measured with bench.sh.

StringPython 2.7.11LDC 1.13.0DMD 2.084.0
Thu Sep 25 10:36:28 BRST 2003156 µs10 μs15 μs
2003-09-25T10:49:41.5-03:00136 µs5 μs6 μs
09.25.2003124 µs5 μs7 μs
2003-09-2566.4 µs4 μs5 μs

Difference to Date Parser

The difference to the original dateparser is that this version does not use allocator but plain old new resulting in being able to be called from @safe code.

Authors:
  • Jack Stouffer
  • Robert Schadek
Dependencies:
none
Versions:
4.0.1 2024-Apr-19
4.0.0 2022-Sep-22
~master 2024-Apr-19
Show all 3 versions
Download Stats:
  • 4 downloads today

  • 61 downloads this week

  • 205 downloads this month

  • 4555 downloads total

Score:
1.8
Short URL:
dateparser2.dub.pm