Skip to content

Natural language date parsing in Java, ported directly from Ruby's chronic

License

Notifications You must be signed in to change notification settings

samtingleff/jchronic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jchronic

Introduction

A natural language date parser in Java. Originally written by Mike Schrag as a direct port of Ruby's chronic.

I've forked it out of WONDER, "an umbrella project for the WebObjects community."

Maven

<dependencies>
    <dependency>
        <groupId>com.rubiconproject.oss</groupId>
        <artifactId>jchronic</artifactId>
        <version>0.2.8</version>
    </dependency>
</dependencies>

Parsing of two-digit years

The parsing of two-digit years can be controlled with one of the Pointer.PointerType values NONE, PAST or FUTURE like this:

Options opts = new Options(Pointer.PointerType.PAST);
Span result = Chronic.parse("1/2/38", options);   // Year is treated as 1938 because of PointerType.PAST.

The behavior is like this:

PointerType 1-19 20-37 38-68 69-99 100-137
NONE 20xx 20xx error 19xx 20xx
PAST 20xx 19xx 19xx 19xx 20xx
FUTURE 20xx 20xx 20xx 19xx 20xx

Earlier versions of this library ignored the given options and always behaved like the NONE line in the table.

Credits

This was originally written by Mike Schrag as part of the WONDER project.

Additional contributions have since been made by @brianm, @ewanmellor, and @samtingleff.

License

The MIT license. See LICENSE.

About

Natural language date parsing in Java, ported directly from Ruby's chronic

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages