Use Date.js parse method not for the current date

62 views Asked by At

I want to use a javascript library(like Date.js) to parse natural language expressions such as "next tuesday" or "tommorow" but it seems that it evaluates the expression based on current date for example:

Given today's date is: Mon Mar 09 2015 00:00:00 GMT+0100 (CET)

Input: Date.parse('next tuesday');

Output: Tue Mar 10 2015 00:00:00 GMT+0100 (CET)

I would like to parse the expression "next tuesday" given a specific date. Is there a way how one can achieve this using date.js or any other Javascript Library(I tried sugarjs too)? Am I missing something here?

1

There are 1 answers

4
Danmoreng On

Set today to the date you want to have and make your parse.

https://code.google.com/p/datejs/wiki/APIDocumentation#set

Probably read the API before asking this question.