SkillAgentSearch skills...

KurdishDate

Javascript date library for parsing, validating, manipulating, and formatting date in Kurdish, Persian, Islamic and Gregorian, based on PersianDate (https://github.com/babakhani/PersianDate)

Install / Use

/learn @Freydoonk/KurdishDate
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Kurdish Date

Javascript date library for parsing, validating, manipulating, and formatting date in Kurdish, Persian, Islamic and Gregorian, based on PersianDate

Install

npm install kurdish-date --save-dev
yarn add kurdish-date --dev

Browser

<script src="node_modules/kurdish-date/lib/kurdishDate.js" type="text/javascript"></script>
<script src="node_modules/kurdish-date/lib/declarations.js" type="text/javascript"></script>
<script type="text/javascript">
    var date = new kurdishDate.defualt().toLocale(LocaleType.en).format();  // "2718-01-17T11:20:25+03:30" //
</script>

Webpack

var kurdishDate = require("kurdish-date")
var now = new kurdishDate.default();

Typescript

import kurdishDate from "kurdish-date";
import { CalendarType, LocaleType } from "kurdish-date/lib/declarations";

Calendar and locale

toCalendar

Default: Kurdish Available option in CalendarType: Kurdish Persian Gregorian Islamic

Change calendar type globally:

KurdishDate.toCalendar(CalendarType.Gregorian);
new KurdishDate([2018]).year(); // 2017
new KurdishDate([2018]).format("MMM"); // "یەنایر"

or change calendar type on instance:

new KurdishDate([2718]).toCalendar(CalendarType.Gregorian).year(); // 2018

toLocale

Default: ku Available option in LocaleType: ku fa en

Change locale globally:

KurdishDate.toLocale(LocaleType.en);
new KurdishDate([2718, 1, 17]).format();       // "2718-01-17T00:00:00+03:30"
new KurdishDate([2718, 1, 17]).format("dddd"); // "Friday"
new KurdishDate([2718, 1, 17]).format("MMMM"); // "Xakelêw"

KurdishDate.toLocale(LocaleType.ku);
new KurdishDate([2718, 1, 17]).format();       // "٢٧١٨-٠١-١٧T٠٠:٠٠:٠٠+٠٣:٣٠"
new KurdishDate([2718, 1, 17]).format("dddd"); // "هه‌ینی"
new KurdishDate([2718, 1, 17]).format("MMMM"); // "خاکه‌لێوه"

or change locale on instance:

new KurdishDate([2718, 1, 17]).toLocale(LocaleType.en).format();       // "2718-01-17T00:00:00+03:30"
new KurdishDate([2718, 1, 17]).toLocale(LocaleType.en).format("dddd"); // "Friday"
new KurdishDate([2718, 1, 17]).toLocale(LocaleType.en).format("MMMM"); // "Xakelêw"

KurdishDate.toCalendar(CalendarType.Gregorian);
new KurdishDate([2718, 1, 17]).toLocale(LocaleType.ku).format();       // "٢٧١٨-٠١-١٧T٠٠:٠٠:٠٠+٠٣:٣٠"
new KurdishDate([2718, 1, 17]).toLocale(LocaleType.ku).format('dddd'); // "هه‌ینی"
new KurdishDate([2718, 1, 17]).toLocale(LocaleType.ku).format('MMMM'); // "خاکه‌لێوه"

Initialize instance

Simply call new KurdishDate() to get an instance of KurdishDate.

Now

To get the current date and time, just call new KurdishDate() with no parameters.

let now = new KurdishDate();

This is essentially the same as calling new KurdishDate(new Date()) .

Unix Offset (milliseconds)

new KurdishDate(/* Number */);

Similar to new Date(Number), you can create a KurdishDate by passing an integer value representing the number of milliseconds since the Unix Epoch (Jan 1 1970 12AM UTC).

let day = new KurdishDate(1318781876406); // "٢٧١١-٠٧-٢٤ ١٩:٤٧:٥٦ د.ن"

Date

new KurdishDate(new Date());

You can create a KurdishDate with a pre-existing native Javascript Date object.

let day = new Date(2018, 2, 16);
let dayWrapper = new KurdishDate(day); // "٢٧١٧-١٢-٢٥ ٠٠:٠٠:٠٠ ب.ن"

This is the fastest way to get a KurdishDate.js wrapper.

Array

['year', 'month', 'day', 'hour', 'minute', 'second', 'millisecond']

new KurdishDate([2718, 1, 7, 12, 25, 25, 900]); 

You can create a KurdishDate with an array of numbers that mirror the parameters passed to new Date() But As Kurdish Date Number Like [2718,2,22,11,22,30]

new KurdishDate([2718, 1, 7, 12, 25, 25, 900]); // "٢٧١٨-٠١-٠٧ ١٢:٢٥:٢٥ د.ن"

Any value past the year is optional, and will default to the lowest possible number.

new KurdishDate([2718]);    // ٢٧١٨/٠١/٠١
new KurdishDate([2718, 6]); // ٢٧١٨/٠٦/٠١

You can pass Islamic, Gregorian or Persian date array to create instance. for this functionality you must change calendar type by toCalendar(CalendarType.Gregorian), toCalendar(CalendarType.Islamic) and ...

example:

KurdishDate.toCalendar(CalendarType.Gregorian);
new KurdishDate([2018, 3, 25]).format("YYYY/MM/DD"); // "٢٠١٨/٠٣/٢٥"

KurdishDate Clone

new KurdishDate(otherKurdishDate);

All KurdishDate are mutable. If you want a clone of a KurdishDate, you can do so explicitly or implicitly. Calling KurdishDate() on a KurdishDate will clone it.

let a = new KurdishDate([2718]);
let b = new KurdishDate(a);
a.year(2710);
b.year(); // 2718
let a = new KurdishDate([2718]);
let b = a.clone();
a.year(2710);
b.year(); // 2718

Get + Set

kurdishDate.js uses overloaded getters and setters.Calling these methods without parameters acts as a getter, and calling them with a parameter acts as a setter.

new KurdishDate().second(30); // 30
new KurdishDate().second() === 30; // true

Millisecond

new KurdishDate().millisecond(100);
new KurdishDate().millisecond(); // 100

Gets or sets the milliseconds.

Accepts numbers from 0 to 999. If the range is exceeded, it will bubble up to the seconds.

Second

new KurdishDate().second(10);
new KurdishDate().second(); // 10

Gets or sets the seconds.

Accepts numbers from 0 to 59. If the range is exceeded, it will bubble up to the minutes.

Minute

new KurdishDate().minute(20);
new KurdishDate().minute(); // 20

Gets or sets the minutes.

Accepts numbers from 0 to 59. If the range is exceeded, it will bubble up to the hours.

Hour

new KurdishDate().hour(12);
new KurdishDate().hour(); // 12

Gets or sets the hour.

Accepts numbers from 0 to 23. If the range is exceeded, it will bubble up to the day.

Date of Month

new KurdishDate().date(23);
new KurdishDate().date(); // 23

Gets or sets the day of the month.

Accepts numbers from 1 to 31. If the range is exceeded, it will bubble up to the months.

Note: KurdishDate#date is for the date of the month, and KurdishDate#day is for the day of the week.

Year

new KurdishDate().year(2718);
new KurdishDate().year(); // 2718

Gets or sets the year.

Accepts numbers from -270,000 to 270,000.

Day of Week

new KurdishDate().day(); // Number

Gets the day of the week.

Note: KurdishDate#date is for the date of the month, and KurdishDate#day is for the day of the week.

Manipulate

You can change any part of date by manipulate functions. To specific the date part you must use DatePartKey, The DatePartKey is contains bellow keys:

  • Year
  • Month
  • Week
  • Day
  • Hour
  • Minute
  • Second
  • Millisecond
new KurdishDate().add(DatePartKey.Day, 7).subtract(DatePartKey.Month, 1);

Note: It should be noted that KurdishDates are mutable. Calling any of the manipulation methods will change the original KurdishDate.

If you want to create a copy and manipulate it, you should use KurdishDate#clone before manipulating the KurdishDate.

Add

new KurdishDate().add(DatePartKey, Number);

Mutates the original KurdishDate by adding time.

This is a pretty robust function for adding time to an existing KurdishDate. To add time, pass the DatePartKey of what time you want to add, and the amount you want to add.

new KurdishDate().add(DatePartKey.Day, 7);

If you want to add multiple different keys at the same time, you can pass them in as an object literal.

new KurdishDate().add(DatePartKey.Day, 7).add(DatePartKey.Month, 1); // with chaining

There are no upper limits for the amounts, so you can overload any of the parameters.

new KurdishDate().add(DatePartKey.Milliseconds, 1000000); // a million milliseconds
new KurdishDate().add(DatePartKey.Days, 360); // 360 days

Subtract

new KurdishDate().subtract(DatePartKey, Number);

Mutates the original KurdishDate by subtracting time.

This is exactly the same as KurdishDate#add , only instead of adding time, it subtracts time.

new KurdishDate().subtract(DatePartKey.Day, 7);

Start of Time

new KurdishDate().startOf(DatePartKey);

Mutates the original KurdishDate by setting it to the start of a unit of time.

new KurdishDate().startOf(DatePartKey.Year);   // set to the first of the first month, 12:00 am this year
new KurdishDate().startOf(DatePartKey.Month);  // set to the first of this month, 12:00 am
new KurdishDate().startOf(DatePartKey.Week);   // set to the first day of this week, 12:00 am
new KurdishDate().startOf(DatePartKey.Day);    // set to 12:00 am today
new KurdishDate().startOf(DatePartKey.Hour);   // set to now, but with 0 mins, 0 secs, and 0 ms
new KurdishDate().startOf(DatePartKey.Minute); // set to now, but with 0 seconds and 0 milliseconds
new KurdishDate().startOf(DatePartKey.Second); // same as KurdishDate().millisecond(0);

These shortcuts are essentially the same as the following.

new KurdishDate().startOf(DatePartKey.Year);
let now = new KurdishDate();
now.month(1);
now.date(1);
now.hour(0)
now.minute(0);
now.second(0);
now.millisecond(0);
new KurdishDate().startOf(DatePartKey.Hour);
let now = new KurdishDate();
now.minute(0);
now.second(0);
now.millisecond(0);

End of Time

new KurdishDate().endOf(DatePartKey);

Mutates the original KurdishDate by setting it to the end of a unit o

View on GitHub
GitHub Stars4
CategoryDevelopment
Updated8mo ago
Forks2

Languages

TypeScript

Security Score

77/100

Audited on Jul 13, 2025

No findings