opensource-nepal / node-nepali-datetime

A Node project designed to support native JavaScript-like features for Nepali date and times. It includes features such as 'NepaliDate' for Nepali date support and 'dateConverter' for date conversions.
GNU General Public License v3.0
63 stars 18 forks source link

Add support for devanagari date string while parsing #77

Open aj3sh opened 8 months ago

aj3sh commented 8 months ago

This feature allows us to take input from Devanagari strings such as "२०७८-०१-१८" into the NepaliDate object. The current parse module should handle the Devanagari string so that the NepaliDate object can be initialized from such class.

const nepaliDate = new NepaliDate("२०७८-०१-१८")

The steps for parsing are like below:

  1. The input (can be both English or Devanagari string)
  2. Translate the Devanagari date strings to English strings. Translation includes numbers, months, and months abbrs.
  3. Use the translated English string for parsing.
binodnepali commented 6 months ago

In my opinion, we should stick to how native js date initialisation works.

aj3sh commented 6 months ago

@binodnepali, Thanks for sharing your thoughts. We are adding this feature because we already have a method for formatting in Nepali (.formatNepali), and now we need one for parsing it. Other Nepali date tools are also considering or already have this feature.

If we want to keep initialization simple, we could add a static method like parseNepali(...), which acts as the opposite of formatNepali.

Let's also wait for others' opinions.