Giter Club home page Giter Club logo

date-parser's Issues

new release for new dmd

the old version of emsi_containers in the latest tagged release of dateparser (2.1.1) doesn't compile with recent dmd, so a release of date-parser with the updated dub.json would be useful.

Shouldn't be parse("Sep 2003") an interval?

Sep 2003 sounds more like (1 september -> 30 september 2003) rather than 1 september 2003.

Maybe everything should be parsed as interval 2003/09/01 ==> ( 2003/09/01 00:00:00.0000 2003/09/01 23:59:59.9999) . Maybe a [) interval works better.

Then from code you can ignore interval and take only interval begin if it's ok for you.

Instead of an interval a couple date, duration can be used too.

call parse in static this() result in: Program exited with code -11

#!/usr/bin/env dub
/+ dub.sdl:
dependency "dateparser" version="~>3.0.2"
+/

import std.stdio;
import std.datetime;
import dateparser;

shared static this() {
}

void main() {
  writeln(parse("2260-12-25"));
}

in main it's ok:

$ dub ab.d 
2260-Dec-25 00:00:00

But, if in static this:

shared static this() {
  writeln(parse("2260-12-25"));
}

void main() {
}

$ dub ab.d 
Program exited with code -11

Ignore timezone

I'd like to ignore timezone with this code

assert(parse("Sat, 12 Mar 2016 01:30:59 -0900", null, /* ignoreTimezone */ true) == SysTime(DateTime(2016, 3, 12, 01, 30, 59)));

but I got the output

core.exception.RangeError@../../.dub/packages/dateparser-master/src/dateparser.d(1142): Range violation

Restructure Files

Having the source files in the global scope makes no sense. Restructure everything to under dateparser, e.g. dateparser.parse.

This is a breaking change.

Unknown string format for "Thu Nov 07 2019 17:00:00 GMT+0000 (UTC)"

This is the default string format javascript applications output which some servers actually use for serving to their frontend...

Would be great to have this supported. Examples:

Thu Nov 07 2019 17:00:00 GMT+0000 (UTC)
Mon Dec 09 2019 16:26:16 GMT+0100 (Central European Standard Time)

Removing the extra comment (UTC) or (Central European Standard Time) at the end seems to be enough to fix this but this might actually be useful if this was already done from inside the library.

For now I'm using a custom parse function which pre-processes the string:

auto parseDate(const(char)[] s)
{
	import dateparser : parseDateRaw = parse;

	if (s.endsWith(")"))
    {
    	auto end = s.lastIndexOf('(');
		if (end != -1)
        	s = s[0 .. end].strip;
        return parseDateRaw(s);
	}
    else
    	return parseDateRaw(s);
}

std.experimental.allocator.common.Ternary conflict on build

experimental_allocator 2.70.0-b1: building configuration "library"...
/home/vagrant/.dub/packages/experimental_allocator-2.70.0-b1/experimental_allocator/src/std/experimental/allocator/package.d(322,13): Error: std.experimental.allocator.common.Ternary at /home/vagrant/.dub/packages/experimental_allocator-2.70.0-b1/experimental_allocator/src/std/experimental/allocator/common.d(14,1) conflicts with std.typecons.Ternary at /usr/include/dmd/phobos/std/typecons.d(8744,1)
/home/vagrant/.dub/packages/experimental_allocator-2.70.0-b1/experimental_allocator/src/std/experimental/allocator/package.d(328,13): Error: std.experimental.allocator.common.Ternary at /home/vagrant/.dub/packages/experimental_allocator-2.70.0-b1/experimental_allocator/src/std/experimental/allocator/common.d(14,1) conflicts with std.typecons.Ternary at /usr/include/dmd/phobos/std/typecons.d(8744,1)
/home/vagrant/.dub/packages/experimental_allocator-2.70.0-b1/experimental_allocator/src/std/experimental/allocator/package.d(348,13): Error: std.experimental.allocator.common.Ternary at /home/vagrant/.dub/packages/experimental_allocator-2.70.0-b1/experimental_allocator/src/std/experimental/allocator/common.d(14,1) conflicts with std.typecons.Ternary at /usr/include/dmd/phobos/std/typecons.d(8744,1)

Not properly handling utf-8 graphemes

This fails

import std.range;
import std.utf;
import std.datetime;
import dateparser;
import std.experimental.allocator.gc_allocator;

class RusParserInfo : ParserInfo
{
    this()
    {
        super(false, false);
        monthsAA = ParserInfo.convert([
            ["янв", "Январь"],
            ["фев", "Февраль"],
            ["мар", "Март"],
            ["апр", "Апрель"],
            ["май", "Май"],
            ["июн", "Июнь"],
            ["июл", "Июль"],
            ["авг", "Август"],
            ["сен", "Сентябрь"],
            ["окт", "Октябрь"],
            ["ноя", "Ноябрь"],
            ["дек", "Декабрь"]
        ]);
    }
}

void main()
{
    auto rusParser = new Parser!GCAllocator(new RusParserInfo());
    immutable parsedTime = rusParser.parse("10 Сентябрь 2015 10:20".byChar);
    assert(parsedTime == SysTime(DateTime(2015, 9, 10, 10, 20)));
}

Removing the byChar makes it work due to auto decoding, but this is indicative of a larger problem.

Should support dateutil style default date

Many uses of dateutil's parser include parsing times of the day in relation to the current date. This is not currently possible, so there should be an API for adding a default date to apply the given information on top of.

This would be a breaking change

Allow any type of string to be parsed

Currently, only strings with char encoding can be parsed; this must be fixed. The main blocker to this is ParserInfo, which uses string for it's AA keys. ParserInfos are initialized separate from the parser function, so it has no knowledge of the encoding type of the string being parsed.

Ranges of graphemes should be supported as well.

Intervals support

Hello, can you privide some method to parse intervals like

5 sec, 20 min, 20min 30sec,1 month 5hour, etc

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.