Is there a natural language parser for date/times in javascript?
Does Date.js satisfy your needs? Or are you looking for something else?
SugarJS supports some natural language parsing of dates and times.
You can jump to the live example here: http://sugarjs.com/dates
For example, it supports the following inputs:
You can then covert the result into different date formats or use the API to further manipulate the date.
For node, I've found chrono to work well
Chrono supports most date and time formats, such as :
You can use the jQuery datepicker translation, get the day and month number and select the day from datepicker days.
You can add values to this object, and you can download up to 60 languages I think. (The object below is not complete, I removed some code to simplify it).
$.datepicker.regional['sv'] = {
monthNames:['Januari','Februari','Mars','April','Maj','Juni','Juli','Augusti','September','Oktober','November','December'],
monthNamesShort: ['Jan','Feb','Mar','Apr','Maj','Jun','Jul','Aug','Sep','Okt','Nov','Dec'],
dayNamesShort: ['Sön','Mån','Tis','Ons','Tor','Fre','Lör'],
dayNames: ['Söndag','Måndag','Tisdag','Onsdag','Torsdag','Fredag','Lördag'],
dayNamesMin: ['Sö','Må','Ti','On','To','Fr','Lö']
};
Now get the day and month number
var dateObject = new Date();
var day = dateObject.getDay();
var month = dateObject.getMonth();
var monthText = $.datepicker.regional['sv']['monthNames'][month];
var dayText = $.datepicker.regional['sv']['dayNames'][day];
I made Chrono a small library for parsing dates in JavaScript. I added a date range parsing feature (such as '12 Nov - 13 Dec 2012') .