Skip to content

A natural language date parser in Dart. Inspired by @wanasit/chrono.

License

Notifications You must be signed in to change notification settings

guacamoly/chrono_dart

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chrono - Date parser for Dart (Flutter)

pub.dev/packages/chrono_dart License: MIT

A natural language date parser in Dart. Finds and extracts dates from user-generated text content.

Example use case – WhatsApp-like date parsing in dialogues: chrono_dart

It is designed to handle most date/time formats and extract information from any given text:

  • Today, Tomorrow, Yesterday, Last Friday, etc
  • 17 August 2013 - 19 August 2013
  • This Friday from 13:00 - 16.00
  • 5 days ago
  • 2 weeks from now
  • Sat Aug 17 2013 18:40:39 GMT+0900 (JST)
  • 2014-11-30T08:15:30-05:30

Usage

  1. Install manually or via pub - dart pub add chrono_dart
  2. Simply pass a string to functions Chrono.parseDate or Chrono.parse.
import 'package:chrono_dart/chrono_dart.dart' show Chrono;

Chrono.parseDate('An appointment on Sep 12');
// DateTime('2023-09-12 12:00:00.000Z')
    
Chrono.parse('An appointment on Sep 12');
/* [<ParsingResult>{ 
    index: 18,
    text: 'Sep 12',
    date() => DateTime('2023-09-12T12:00:00'),
    ...
}] */

Only English is supported in this version. Feel free to add PRs with any other languages – the package is designed with extendability in mind.


Port of Chrono to Dart lang. For extended API information see the original package.

About

A natural language date parser in Dart. Inspired by @wanasit/chrono.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 100.0%