A pure dart package with collection of Nepali Utilities like Date converter, Date formatter, DateTime, Nepali Numbers, Nepali Unicode, Nepali Moments and many more.

Overview

Nepali Utilities for Dart

Pub licence Top Language effective dart

A pure dart package with collection of Nepali Utilities like Date converter, Date formatter, DateTime, Nepali Number, Nepali Unicode, Nepali Moments and many more.

Utility Classes

  • NepaliDateTime
  • DateConversion
  • NepaliDateFormat
  • NepaliNumberFormat
  • NepaliUnicode
  • NepaliMoment
  • many yet to come

Language Setup

Default language for Nepali Utility classes can be set as:

void main(){
    NepaliUtils(Language.nepali);
}

This is completely optional. Default language will be English if not set.

Nepali Date Time

The class is similar to dart:core's DateTime class, except that, this works with Bikram Sambat.

NepaliDateTime gorkhaEarthQuake = NepaliDateTime.parse('2072-01-12T11:56:25');
print(gorkhaEarthQuake.year); // 2072

NepaliDateTime currentTime = NepaliDateTime.now();
print(currentTime.toIso8601String()); //2076-02-01T11:25:46.490980
print(gorkhaEarthQuake.mergeTime(10, 20, 30));
// 2072-01-12 10:20:30.000

Date Conversion

Converts dates from AD to BS and vice versa.

NepaliDateTime nt = DateTime(2019, 8, 03, 14, 30, 15).toNepaliDateTime();
print('In BS = $nt'); //2076-04-18 14:30:15.000
DateTime dt = nt.toDateTime(); //2019-08-03 14:30:15.000
print('In AD = $dt');

Nepali Date Formatter

Formats NepaliDateTime into desired format. Formats NepaliDateTime into desired format.

Constructor table for quick formatting:

Constructor Result
d 18
E Sat
EEEE Saturday
LLL Shr
LLLL Shrawan
M 4
Md 4/18
MEd Sat, 4/18
MMM Shr
MMMd Shr 18
MMMEd Saturday, Shr 18
MMMM Shrawan
MMMMd Shrawan 18
MMMMEEEEd Saturday, Shrawan 18
QQQ Q2
QQQQ 2nd quarter
y 2076
yM 2076/04
yMd 2076/04/18
yMEd Sat, 2076/04/18
yMMM Shr 2076
yMMMd Shr 18, 2076
yMMMEd Sat, Shr 18, 2076
yMMMMM Shrawan 2076
yMMMMd Shrawan 18, 2076
yMMMMEEEEd Saturday, Shrawan 18, 2076
yQQQ Q2 2076
yQQQQ 2nd quarter 2076
H 21
Hm 21:04
Hms 21:17:56
j 9 PM
jm 9:17 PM
jms 9:17:56 PM
m 9
ms 9:17
s 56

Example:

var date1 = NepaliDateFormat.MEd();
var date2 = NepaliDateFormat.MMMMEEEEd();
var date3 = NepaliDateFormat.jms();

print(date1.format(gorkhaEarthQuake)); // Sat, 1/12 
print(date2.format(gorkhaEarthQuake)); // Saturday, Baisakh 18
print(date3.format(gorkhaEarthQuake)); // 11:56:00 AM

Formats can also be specified with a pattern string.

Symbol Meaning Presentation Example (en / np)
G era designator (Text) BS / बि सं
GG era designator (Text) B.S. / बि.सं.
GGG era designator (Text) Bikram Sambat / बिक्रम संबत
y year (Number) 1996 / १९९६
yy year (Number) 96 / ९६
yyyy year (Number) 1996 / १९९६
Q quarter (Text) 3
QQ quarter (Text) 03
QQQ quarter (Text) Q3
QQQQ quarter (Text) 3rd quarter
M month in year (Text & Number) 1 / १
MM month in year (Text & Number) 01 / ०१
MMM month in year (Text & Number) Bai / बै
MMMM month in year (Text & Number) Baishakh / बैशाख
d day in month (Number) 9 / ९
dd day in month (Number) 09 / ०९
E day of week (Text) M / सो
EE day of week (Text) Mon / सोम
EEE day of week (Text) Monday / सोमबार
a am/pm marker (Text) pm / बेलुकी
aa am/pm marker (Text) PM / बेलुकी
h hour in am/pm(1~12) (Number) 2 / २
hh hour in am/pm(1~12) (Number) 02 / ०२
H hour in day (0~23) (Number) 14 / १४
HH hour in day (0~23) (Number) 14 / १४
m minute in hour (Number) 3 / ३
mm minute in hour (Number) 03 / ०३
s second in minute (Number) 55 / ५५
s second in minute (Number) 55 / ५५
S fractional second (Number) 978 / ९७८
' escape for text (Delimiter) 'Date='
'' single quote (Literal) 'o''clock'

Example:

var date1 = NepaliDateFormat("yyyy.MM.dd G 'at' HH:mm:ss");
var date2 = NepaliDateFormat("EEE, MMM d, ''yy");
var date3 = NepaliDateFormat("h:mm a");
var date4 = NepaliDateFormat("hh 'o''clock' aa");
var date5 = NepaliDateFormat("yyyy.MMMM.dd GGG hh:mm a");

print(date1.format(gorkhaEarthQuake)); // 2072.01.12 BS at 11:56:25
print(date2.format(gorkhaEarthQuake)); // Saturday, Bai 12, '72
print(date3.format(gorkhaEarthQuake)); // 11:56 am
print(date4.format(gorkhaEarthQuake)); // 11 o'clock AM
print(date5.format(gorkhaEarthQuake)); // 2072.Baishakh.12 Bikram Sambat 11:56 am

Note: Always wrap pattern string in double quote (").

Nepali Number

Converts English numbers into Nepali number literals.

var currencyFormat = NepaliNumberFormat(
    symbol: 'Rs.',
);
var commaSeparated = NepaliNumberFormat(
    decimalDigits: 2,
);
var inWords = NepaliNumberFormat(
    inWords: true,
    language: Language.NEPALI,
);
var currencyInWords = NepaliNumberFormat(
    inWords: true,
    language: Language.NEPALI,
    isMonetory: true,
    decimalDigits: 2,
);
print('123456 -> ${currencyFormat.format(123456)}');
// 123456 -> 1,23,456

print('123456789.6548 -> ${commaSeparated.format(123456789.6548)}');
// 123456789.6548 -> 12,34,56,789.65

print('123456 -> ${inWords.format(123456)}');
// 123456 -> 1 lakh 23 thousand 4 hundred 56

print('123456789.6548 -> ${currencyInWords.format(123456789.6548)}');
// 123456789.6548 -> १२ करोड ३४ लाख ५६ हजार ७ सय ८९ रुपैया ६५ पैसा

Nepali Unicode

Converts English literal (Roman Literals) into Nepali Unicode.

print(NepaliUnicode.convert("sayau' thu''gaa fUlakaa haamii, euTai maalaa nepaalii"));
print(NepaliUnicode.convert("saarwabhauma bhai failiekaa, mecii-mahaakaalii\n"));

// स​यौं थुँगा फूलका हामी, एउटै माला नेपाली
// सार्वभौम भै फैलिएका, मेची-महाकाली

If live conversion is required i.e. conversion as you type, then set live: true.

NepaliUnicode.convert(textFromTextField, live: true);

Nepali Moment

Generates a fuzzy timestamp using dates provided.

print(NepaliMoment.fromBS(NepaliDateTime.parse('2076-03-22T08:41:14')));
// २२ दिन पछि

Here, the current DateTime is 2076-02-32 19:09:25 i.e. reference date

print(NepaliMoment.fromBS(NepaliDateTime.parse('2076-02-32T18:25:14'),
      referenceDate: NepaliDateTime.parse('2076-02-32T18:34:14')));
// ९ मिनेट पहिले

print(NepaliMoment.fromAD(DateTime.parse('2019-06-02T18:22:14'),
      referenceDate: DateTime.parse('2019-06-15T18:34:14')));
// १३ दिन पहिले

Example

Find more detailed example here.

Contribute

If you want to contribute to the package, please feel free to submit issues or PR at Github Repo.

Also show some love by staring the repo , if you like the package.

License

Copyright (c) 2020 Sarbagya Dhaubanjar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
You might also like...

A flutter date time picker

A flutter date time picker

Flutter Datetime Picker (Pub) flutter_datetime_picker A flutter date time picker inspired by flutter-cupertino-date-picker you can choose date / time

Dec 26, 2022

Beautiful Date Range Picker Dialog For Flutter

Beautiful Date Range Picker Dialog For Flutter

Beautiful Date Range Picker Dialog For Flutter

Dec 22, 2022

Flutter Date & Time Range Picker

Flutter Date & Time Range Picker

F-DateTimeRangePicker Date and Time Range Picker for Flutter Installing: dependencies: f_datetimerangepicker: ^0.2.0 Using: import 'package:f_datet

Jan 18, 2022

Collection of customisable calendar related widgets for Flutter.

Collection of customisable calendar related widgets for Flutter.

calendar_views Collection of customisable calendar related widgets for Flutter. Day View Day View Documentation Set of widgets for displaying a day vi

Sep 8, 2022

A Dart package to help you with managing dates easily.

A Dart package to help you with managing dates easily.

📆 Dateable A Dart package to help you with managing dates easily. Can be used to store, format, convert, construct, parse and serialise dates. Calend

Dec 2, 2021

A Flutter package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) dates.

A Flutter package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) dates.

A Flutter package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) dates.

Dec 21, 2022

A Flutter package allows you to easily implement all calendar UI and calendar event functionality. 👌🔝🎉

A Flutter package allows you to easily implement all calendar UI and calendar event functionality. 👌🔝🎉

calendar_view A Flutter package allows you to easily implement all calendar UI and calendar event functionality. For web demo visit Calendar View Exam

Dec 22, 2022

Flutter calendar week UI package

Flutter calendar week UI package

Flutter calendar week Flutter calendar week UI package IOS | Android: import 'package:flutter_calendar_week/flutter_calendar_week.dart'; CalendarWeek(

Dec 12, 2022

A seasonal foods calendar app written in Dart using Flutter.

A seasonal foods calendar app written in Dart using Flutter.

This project is not actively maintained anymore. However, everybody who wants to do so is more than welcome to work on this project! Thank you for you

Nov 19, 2022
Comments
  • [code]: typo fixes for month

    [code]: typo fixes for month

    Thank you @sarbagyastha brother for the package... As I was using showMaterialDateRangePicker() from the nepali_date_picker package, I found a typo for the short form of Mangsir which was Marg instead of Mang. This pr fixes the typo for this month.

    opened by sachin-dahal 2
  • weekDay must have been weekday

    weekDay must have been weekday

    https://github.com/sarbagyastha/nepali_utils/blob/bd60304f7956b477bb8e68a671ab1ecdd45ad0a4/lib/src/nepali_date_time.dart#L105

    Everything regarding the DateTime and NepaliDateTime is identical except weekDay getter.

    opened by awazgyawali 2
  • Delimiter Added in case of Number format

    Delimiter Added in case of Number format

    heading('With Empty Delimiter'); print('123456 -> ${currencyFormatWithNoDelimiter.format(123456)}'); print('1234 -> ${currencyFormatWithNoDelimiter.format(1234)}'); print('12345 -> ${currencyFormatWithNoDelimiter.format(12345)}'); print('123456 -> ${currencyFormatWithNoDelimiter.format(123456)}'); print('123456789.6548 -> ${delimiterWithDecimal.format(123456789.6548)}');

    heading('With Delimiter'); print('123456 -> ${currencyFormatWithDelimiter.format(123456)}'); print('1234 -> ${currencyFormatWithDelimiter.format(1234)}'); print('12345 -> ${currencyFormatWithDelimiter.format(12345)}'); print('123456 -> ${currencyFormatWithDelimiter.format(123456)}'); print( '1234567.891 -> ${currencyFormatWithDelimiterAndDecimal.format(1234567.891)}');

    image

    opened by ravikant-paudel 0
Owner
Sarbagya Dhaubanjar
Senior Software Engineer at @khalti
Sarbagya Dhaubanjar
Datetime picker formfield - A Flutter widget that wraps a TextFormField and integrates the date and/or time picker dialogs.

DateTimeField A TextFormField that emits DateTimes and helps show Material, Cupertino, and other style picker dialogs. Example See the example tab (ex

Jacob Phillips 182 Dec 1, 2022
A DateTime picker that lets user to select a date and the time, with start & end as a range

Omni DateTime Picker A DateTime picker that lets user to select a date and the time, with start & end as a range. Screenshots Getting started Add this

null 17 Dec 29, 2022
⏰ Type-safe DateTime and Duration calculations, powered by extensions.

⏰ Time With shiny extensions, if you have ever written something like this, then look no further: final DateTime fourHoursFromNow = DateTime.now() + D

Jeremiah Ogbomo 467 Dec 28, 2022
Allows to use date pickers without dialog. Provides some customizable styles for date pickers.

flutter_date_pickers Allows to use date pickers without dialog. Provides some customizable styles for date pickers. A set of date pickers: DayPicker f

null 196 Dec 29, 2022
Highly customizable, feature-packed calendar works like google calendar but with more features.

Beca [In Progress] Beca is a Calendar that you could manage your daily tasks and schedule meetings with your friends just like google calendar Concept

Mohammad Javad Hossieni 19 Nov 15, 2022
A Flutter package for adding a DateRange widget into a form. A date picker UX is provided by showDateRangePicker.

A Flutter package for adding a DateRange widget into a form. A date picker UX is provided by showDateRangePicker.

JMA Consulting 9 Mar 12, 2022
Flutter package to create a day date scroller

scrolling_day_calendar A flutter calendar package to allow users to scroll through given dates either by swiping left and right or pressing the arrows

null 8 Jul 12, 2020
Flutter Date Picker Library that provides a calendar as a horizontal timeline.

DatePickerTimeline Flutter Date Picker Library that provides a calendar as a horizontal timeline. How To Use Import the following package in your dart

LiLi 0 Oct 25, 2021
Flutter Cupertino Date Picker

Flutter Cupertino Date Picker [pub packages] | 中文说明 Flutter cupertino date picker. Usage 1. Depend Add this to you package's pubspec.yaml file: depend

Ryuuzaki 0 Nov 9, 2021
Flutter Date Picker Library that provides a calendar as a horizontal timeline

Flutter Date Picker Library that provides a calendar as a horizontal timeline.

Vivek Kaushik 214 Jan 7, 2023