robertwilczynski / nChronic

A natural language date/time parser ported from Ruby
MIT License
67 stars 34 forks source link

Global EndianPrecedence configuration isn't available #20

Open adebisi-fa opened 7 years ago

adebisi-fa commented 7 years ago

Hi,

It appears it is currently not possible to GLOBALLY configure the default EndianPrecedence property of Options for new instances of the Chronic.Parser type, like it is available in the ruby clone (please check out this comment).

A public static non readonly field, as created for DefaultAmbiguousTimeRange, should be enough, like so:

// readonly modifier removed to allow re-configuration per AppDomain.
public static EndianPrecedence DefaultEndianPrecedence = EndianPrecedence.Middle;

then, can be used in the constructor like so:

...
EndianPrecedence = DefaultEndianPrecedence;
...

This will make the EndianPrecedence configuration globally, (say in Global.asax Application_Start), viz:

     protected void Application_Start(object sender, EventArgs e) {
          . . .
          Chronic.Options.DefaultEndianPrecedence = EndianPrecedence.Little;
          . . . 
     }

Can you please kindly get this fixed, or will a pull request be better?

Thanks, please.