Nepali date converter open source

Date converter is a program that converts English date to Nepali date and Nepali date to English date. Date converter is quite a bit problem for a developer. It takes some times to code date converter program. I have provided a open source date converter program for a developer with five different programming languages ( Java, PHP, Python, JavaScript, C Sharp ). My date converter converts within a range of 2000BS to 2098BS or 1944AD to 2042AD . It is easy to use and already test with different environments.

The features of the Date converter are :

  1. Converts English date to Nepali date.
  2. Converts Nepali date to English date.
  3. Determine the current date.
  4. Determine the day of a week.
  5. Calculate difference in days with another date ( either AD or BS)


The methods are:

  1. setCurrentDate()
    sets the current date
  2. setEnglishDate(year, month, date)
    sets the English date with year month and date
  3. setNepaliDate(year, month, date)
    sets the Nepali date with year month and date
  4. toEnglishString(format = "-")
    returns English date with format eg. 2017-11-13
  5. toNepaliString(format = "-")
    returns Nepali date with format eg. 2074-7-27
  6. getEnglishDateDifference(year, month, date)
    returns difference in days with current date to the English date arguments
  7. getNepaliDateDifference(year, month, date)
    returns difference in days with current date to the Nepali date arguments
  8. getEnglishYear()
    returns English date year
  9. getEnglishMonth()
    returns English date month
  10. getEnglishDate()
    returns English date date
  11. getNepaliYear()
    returns English date year
  12. getNepaliMonth()
    returns English date month
  13. getNepaliDate()
    returns English date date
  14. getDay()
    returns weekly day in number [1 - 7]


Source files

  1. Java

    Download java source file ( .java )

    Example
    try {
       
        DateConverter converter = new DateConverter();
       
        converter.setNepaliDate(2074, 7, 26);
        System.out.println(converter.getEnglishYear()+"/"+converter.getEnglishMonth()+"/"+converter.getEnglishDate());
        System.out.println(converter+"\n");
       
        converter.setCurrentDate();
        System.out.println(converter.getNepaliYear()+"/"+converter.getNepaliMonth()+"/"+converter.getNepaliDate());
        System.out.println("Weekly day: "+converter.getDay());
        System.out.println(converter.toNepaliString());

    } catch (Exception e) {
        //Invalid date format
        System.out.println(e.toString());
    }
  2. PHP

    Download php source file ( .php )

    Example
    include("DateConverter.php");

    $converter = new DateConverter();

    $converter->setNepaliDate(2074,7,26);
    echo $converter->getEnglishYear()."/".$converter->getEnglishMonth()."/".$converter->getEnglishDate();
    echo $converter;

    $converter->setCurrentDate();
    echo $converter->getNepaliYear()."/".$converter->getNepaliMonth()."/".$converter->getNepaliDate();
    echo "Weekly day: ".$converter->getDay();
    echo $converter->toNepaliString();
  3. Python

    Download python source file ( .py )

    Example
    from DateConverter import DateConverter

    converter = DateConverter()
    converter.setNepaliDate(2074, 7, 26)
    print(str(converter.getEnglishYear())+"/"+str(converter.getEnglishMonth())+"/"+str(converter.getEnglishDate()))
    print(converter)
    print()

    converter.setCurrentDate()
    print(str(converter.getNepaliYear())+"/"+str(converter.getNepaliMonth())+"/"+str(converter.getNepaliDate()))
    print( "Weekly day: "+ str(converter.getDay()) )
    print( converter.toNepaliString() )
  4. JavaScript

    Download javascript source file ( .js )

    Example
    <script src="dateconverter.js"></script>

    <script>
        try{

            var converter = new DateConverter();
            converter.setNepaliDate(2074, 7, 26)
            alert(converter.getEnglishYear()+"/"+converter.getEnglishMonth()+"/"+converter.getEnglishDate())

            converter.setCurrentDate()
            alert(converter.getNepaliYear()+"/"+converter.getNepaliMonth()+"/"+converter.getNepaliDate())
            alert( "Weekly day: "+ converter.getDay() )
            alert( converter.toNepaliString() )
       
        }catch(err)
        {
            alert(err.message);
        }
    </script>
  5. C Sharp ( or C# )

    Download c sharp source file ( .cs )

    Example
    try {

        DateConverter converter = new DateConverter();

        converter.setNepaliDate(2074, 7, 26);
        Console.WriteLine(converter.getEnglishYear()+"/"+converter.getEnglishMonth()+"/"+converter.getEnglishDate());
        Console.WriteLine("");
       
        converter.setCurrentDate();
        Console.WriteLine(converter.getNepaliYear()+"/"+converter.getNepaliMonth()+"/"+converter.getNepaliDate());
        Console.WriteLine("Weekly day: "+converter.getDay());
        Console.WriteLine(converter.toNepalistring());

    } catch (Exception e) {
        //Invalid date format
        Console.WriteLine("Exception information: {0}", e);
    }

Download all source files





You must login to comment

BhuWan KhaDka 4 weeks ago

keep providing open source.....

BhuWan KhaDka 4 weeks ago

sahi x ....daaju

  • Online: 2
    Registered users: 7
    Unique visitors: 3337
    Total hits: 5156


www.000webhost.com