axiom-date-library
v1.0.15
Published
--- #### Author : Axiom ##### Created on : 9th Nov 2015 <!-- ##### Update Date : 10th Nov 2015 --> --- ## constant
Downloads
224
Readme
Date Library
Author : Axiom
Created on : 9th Nov 2015
constant
OperationType
- Day_of_Week
- Day_Number_of_Week
- Absolute_DateTime
- First_Date
- Last_Date
- Date_of_Weekday_in_Week
- Date_of_Weekday_in_Month_for_Given_Week
- Date_of_Weekday_in_Quarter_for_Given_Month_and_Week
- Date_of_Weekday_in_Year_for_Given_Week
- Date_of_Weekday_in_Year_for_Given_Month_and_Week
- Date_of_Weekday_in_Year_for_Given_Quarter_and_Month_and_Week
- Week_of_Year
- Calendar_Week_of_Month
- Week_of_Month_by_Days_Distribution_for_as_Weeks
DOW (Date Of Week)
- Sunday
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday
- Saturday
GranularityType
- Seconds
- Minutes
- Hours
- Days
- Weeks
- Months
- Quarters
- HalfYears
- Years
- FinancialYears
functions
DateLibrary.getDayOfWeek(Date, {JSON Object})
example1
- Description : find Week Name from
15th June 2015
.
DateLibrary.getDayOfWeek(new Date("2015-06-15"), {operationType:"Day_of_Week"}) // Output : Monday
- Steps
- find day of week from given date[
Monday
]
- find day of week from given date[
- Description : find Week Name from
example2
- Description : if first day of week is
Sunday
, what day will be on15th June 2015
.
DateLibrary.getDayOfWeek(new Date("2015-06-15"), {operationType:"Day_Number_of_Week", startDayOfWeek:"Sunday"}) // Output : 1
- Steps
- find Week of given date (Sunday as Start day of week) [
14th May 2015
to20th May 2015
] - Given Date follow in 2nd day [
1
]
- find Week of given date (Sunday as Start day of week) [
- Description : if first day of week is
DateLibrary.getRelativeDate(Date, {JSON Object})
example1
- Description : Subtract 13
Days
From Given Date
DateLibrary.getRelativeDate(new Date("2015-06-15 14:10:39"), {operationType: "Absolute_DateTime", granularityType: "Days",value: -13}) // Output : Tue Jun 02 2015 14:10:39
- Steps
- find Day from given date [
15
] - Subtract 13 Days from given date [
15-13
]
- find Day from given date [
- Description : Subtract 13
example2
- Description : Subtract 13
Hours
From Given Date
DateLibrary.getRelativeDate(new Date("2015-06-15 14:10:39"), {operationType: "Absolute_DateTime", granularityType: "Hours",value: -13}) // Output : Tue Jun 15 2015 01:10:39
- Steps
- find Hours from given date [
14
] - Subtract 13 Hours from given date [
14-13
]
- find Hours from given date [
- Description : Subtract 13
example3
- Description : get First Day of
quarter
From Given Date
DateLibrary.getRelativeDate(new Date("2015-06-15"), {operationType:"First_Date",granularityType:"Quarters"}) // Output : Wed Apr 01 2015 00:00:00
- Steps
- find quarter for given date [
2nd Quarter
] - find first month of quarter [
Apr
]
- find quarter for given date [
- Description : get First Day of
example4
- Description : get Last Day of
quarter
From Given Date
DateLibrary.getRelativeDate(new Date("2015-06-15"), {operationType:"Last_Date",granularityType:"Quarters"}) // Output : Wed Jun 30 2015 23:59:59
- Steps
- find quarter for given date [
2nd Quarter
] - find last month of quarter [
Jun
]
- find quarter for given date [
- Description : get Last Day of
example5
- Description : if first day of week is
Sunday
, what date will be onWednesday
, if given date is15th June 2015
.
DateLibrary.getRelativeDate(iDate, {operationType: "Date_of_Weekday_in_Week", startDayOfWeek:"Sunday",returnDayOfWeek:"Wednesday"}) // Output : Wed Jun 17 2015 00:00:00
- Steps
- find Week of given date (Sunday as Start day of week) [
14th May 2015
to21st May 2015
] - Wednesday will be on [
17th May 2015
]
- find Week of given date (Sunday as Start day of week) [
- Description : if first day of week is
example6
- Description : if first day of week is
Wednesday
, what date will be on1st day of week
, if given date is15th June 2015
.
DateLibrary.getRelativeDate(new Date("2015-06-15"), {operationType:"Date_of_Weekday_in_Week", startDayOfWeek:"Wednesday",returnDayNumberOfWeek:0}) // Output : Wed Jun 10 2015 00:00:00
- Steps
- find Week of given date (Wednesday as Start day of week) [
10th May 2015
to17th May 2015
] - 1st day of week should be [
10th May 2015
]
- find Week of given date (Wednesday as Start day of week) [
- Description : if first day of week is
example7
- Description : if first day of week is
Monday
, what date will be onFriday
of2nd Week
ofMonth
containing15th June 2015
as one of the date.
DateLibrary.getRelativeDate(new Date("2015-06-15"), {operationType:"Date_of_Weekday_in_Month_for_Given_Week", startDayOfWeek: "Monday",returnDayOfWeek:"Friday",WeekOfMonth:2}) // Output : Fri Jun 12 2015 00:00:00
- Steps
- find month for given date [
Jun
] - find 2nd Week of month (Monday as Start day of week) [
8th May 2015
to14th May 2015
] - Friday will be on [
12th May 2015
]
- find month for given date [
- Description : if first day of week is
example8
- Description : if first day of week is
Sunday
, what date will befourth day
of3rd Week
ofMonth
containing15th June 2015
as one of the date.
DateLibrary.getRelativeDate(new Date("2015-06-15"), {operationType: "Date_of_Weekday_in_Month_for_Given_Week", startDayOfWeek:"Sunday",returnDayNumberOfWeek:3,WeekOfMonth:3}) // Output : Wed Jun 17 2015 00:00:00
- Steps
- find month for given date [
Jun
] - find 2nd Week of month (Sunday as Start day of week) [
14th May 2015
to20th May 2015
] - The date of fourth day of week should be [
17th May 2015
]
- find month for given date [
- Description : if first day of week is
example9
- Description : if first day of week is
Tuesday
, what date will be onFriday
of3rd week
of2nd month
ofquarter
containing15th June 2015
as one of the date.
DateLibrary.getRelativeDate(new Date("2015-06-15"), {operationType:"Date_of_Weekday_in_Quarter_for_Given_Month_and_Week", startDayOfWeek:"Tuesday",returnDayOfWeek:"Friday",MonthOfQuarter:2,WeekOfMonth:3}) // Output : 15th May 2015
- Steps
- find quarter for given date [
2nd Quarter
] - find 2nd month of quarter [
May
] - find 3rd week of month (Tuesday as Start day of week) [
12th May 2015
to18th May 2015
] - Friday will be on [
15th May 2015
]
- find quarter for given date [
- Description : if first day of week is
example10
- Description : if first day of week is
Tuesday
, what date will be onSunday
of18th Week
of year containing15th June 2015
as one of the date.
DateLibrary.getRelativeDate(new Date("2015-06-15"), {operationType: "Date_of_Weekday_in_Year_for_Given_Week" , startDayOfWeek: "Tuesday", returnDayOfWeek:"Sunday", WeekOfYear:18}) // Output : 3rd May 2015
- Steps
- find 18 week follow in which month [
May
] - find 18th week of year (Tuesday as Start day of week) [
28th Apr 2015
to4th May 2015
] - Sunday will be on [
3rd May 2015
]
- find 18 week follow in which month [
- Description : if first day of week is
example11
- Description : if first day of week is
Friday
, what date will be onTuesday
of3rd Week
of8th month
of year containing15th June 2015
as one of the date.
DateLibrary.getRelativeDate(new Date("2015-06-15"), {operationType:"Date_of_Weekday_in_Year_for_Given_Month_and_Week", startDayOfWeek:"Friday", returnDayOfWeek:"Tuesday", WeekOfMonth:3, MonthOfYear:8}) // Output : 18th Aug 2015
- Steps
- find 8th month in year [
Aug
] - find 3rd week of Month (Friday as Start day of week) [
14th Aug 2015
to20th Aug 2015
] - Tuesday will be on [
18th Aug 2015
]
- find 8th month in year [
- Description : if first day of week is
example12
- Description : if first day of week is
Friday
, what date will be onTuesday
of3rd Week
of2nd month
of3rd quarter
of year containing15th June 2015
as one of the date.
DateLibrary.getRelativeDate(new Date("2015-06-15"), {operationType: "Date_of_Weekday_in_Year_for_Given_Quarter_and_Month_and_Week", startDayOfWeek:"Friday",returnDayOfWeek:"Tuesday", QuarterOfYear:3, MonthOfQuarter:2, WeekOfMonth:3}) // Output : 18th Aug 2015
- Steps
- find 3rd quarter of year [
Jul
toSep
] - find 2nd month of quarter [
Aug
] - find 3rd week of month (Friday as Start day of week) [
14th Aug 2015
to20th Aug 2015
] - Tuesday will be on [
18th Aug 2015
]
- find 3rd quarter of year [
- Description : if first day of week is
DateLibrary.getWeekNumber(Date, {JSON Object})
example1
- Description : if first day of week is
Tuesday
, what week number in year will be follow in15th June 2015
as one of the date.
DateLibrary.getWeekNumber(new Date("2015-06-15"), {operationType:"Week_of_Year", startDayOfWeek:"Tuesday"}) // Output : 24
- Steps
- find Previous month(s) week count (Tuesday as Start day of week)(
Jan+Feb+Mar+Apr+May
) [5+4+5+4+4
] - find week count of given date month(
Jun
) [2
] - total week count is [
5+4+5+4+4+2
=24
]
- find Previous month(s) week count (Tuesday as Start day of week)(
- Description : if first day of week is
example2
- Description : if first day of week is
Tuesday
, what week number in month will be follow in15th June 2015
as one of the date.
DateLibrary.getWeekNumber(new Date("2015-06-15"), {operationType:"Calendar_Week_of_Month", startDayOfWeek: "Tuesday"}) // Output : 3
- Steps
- find week count of given date month(Tuesday as Start day of week) [
3
] - total week count is [
3
]
- find week count of given date month(Tuesday as Start day of week) [
- Description : if first day of week is
example3
- Description : what week number in month by days distribution will be follow in
15th June 2015
as one of the date.
DateLibrary.getWeekNumber(new Date("2015-06-15"), {operationType:"Week_of_Month_by_Days_Distribution_for_as_Weeks", "28days":[5,6,5,6,6],"29days":[5,6,6,6,6],"30days":[6,6,6,6,6],"31days":[5,5,5,5,5,6]}) // Output : 3
- Steps
- find total days in month [
30
] - find week count given date follow in which week [
6+6+6
=18
] - total week count is [
3
]
- find total days in month [
- Description : what week number in month by days distribution will be follow in
example4
- Description : what is the week number in year where the week starts from Monday and month calculation starts from April.
DateLibrary.getWeekNumber(new Date("2021-05-05"), {operationType:"Week_of_Year", startDayOfWeek:"Monday", startMonth:3}) // Output : 5
- Steps
- find Previous month(s) week count (Monday as Start day of week)(
Apr
) [4
] starting the startMonth i.e April here - find week count of given date month(
May
) [1
] - total week count is [
4+1
=5
]
- find Previous month(s) week count (Monday as Start day of week)(
DateLibrary.getDateDifference(fromDate,toDate,{JSON Object})
example1
- Description : This takes three arguments from Date, to Date and JSON Object .It returns difference between them(base on granularityType days).
DateLibrary.getDateDifference(new Date("2016-04-01"),new Date("2016-04-16"), {granularityType: "days"}) //output 15
example2
- Description : This takes three arguments from Date , to Date and JSON Object .It returns difference between them(base on granularityType seconds).
DateLibrary.getDateDifference(new Date("2016-04-01 12:30:59"),new Date("2016-04-16 15:45:59"), {granularityType: "seconds"}) //output 1307700
DateLibrary.getDifferenceInDays(fromDate,toDate,[array of excluded Date Object],[array of excluded days])
example1
- Description : This takes two arguments from Date and to Date.It returns difference between them.
DateLibrary.getDifferenceInDays(new Date("2016-04-01"),new Date("2016-04-16"))//output 15
example2
- Description : This takes four arguments from Date, to Date and array of dates to be excluded and empty array exclude days.It returns difference between them.
DateLibrary.getDifferenceInDays(new Date("2016-04-01"),new Date("2016-04-16"), [new Date("2016-04-05"),new Date("2016-04-06")],[])//output 13
example3
- Description : This takes four arguments from Date, to Date and array of dates to be excluded and array of days to be excluded.It returns difference between them.
DateLibrary.getDifferenceInDays(new Date("2016-04-01"),new Date("2016-04-16"), [new Date("2016-04-05"),new Date("2016-04-06")],["friday"])//output 10
DateLibrary.getNumberToTimeStr(timeString, {JSON Object})
example1
- Description : This takes two arguments timeString and JSON Object. It returns time.
DateLibrary.getNumberToTimeStr("345", {delimiter: ":"}) //output 00:03:45
example2
- Description : This takes two arguments timeString and JSON Object. It returns time.
DateLibrary.getNumberToTimeStr("5", {delimiter: "-"}) //output 00-00-05
* _example3_ - _Description_ : This takes two arguments timeString and JSON Object. It returns time. ```javascript DateLibrary.getNumberToTimeStr("145635", {delimiter: "~"}) //output 14~56~35 ```
DateLibrary.julianToDate(julianString, timeString)
- example1
- Description : This takes two arguments julianString and timeString (optional). It returns date object.
DateLibrary.julianToDate("102536") //output Fri Jun 20 2003 00:00:00
- example2
- Description : This takes two arguments timeString and JSON Object. It returns time.
DateLibrary.julianToDate("115536","152645") //output Sun Jun 19 2016 15:26:45
- example1