Giter Club home page Giter Club logo

date-parser's Introduction

Date Parser

Build Status Dub codecov

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.

Tested with ldc v1.12.0 - v1.13.0 and dmd v2.081.2 - v2.084.0. May work with earlier versions.

Simple Example

View the docs for more.

import std.datetime;
import dateparser;

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)));
}

Docs

http://jackstouffer.com/dateparser/

Install With Dub

{
    ...
    "dependencies": {
        "dateparser": "~>3.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.

String Python 2.7.11 LDC 1.13.0 DMD 2.084.0
Thu Sep 25 10:36:28 BRST 2003 156 µs 10 μs 15 μs
2003-09-25T10:49:41.5-03:00 136 µs 5 μs 6 μs
09.25.2003 124 µs 5 μs 7 μs
2003-09-25 66.4 µs 4 μs 5 μs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.