Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[ATLAS-104]: Introducing Date & Time Module #54

Closed
wants to merge 31 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
32aa462
add formatDate - DateTime Module
RgnDunes Jan 18, 2024
763e7e0
add formatDateTime - DateTime Module
RgnDunes Jan 18, 2024
a616f42
add formatTime - DateTime Module
RgnDunes Jan 18, 2024
ab60331
add add & subtract - DateTime Module
RgnDunes Jan 18, 2024
0e341d6
add getFirstDayOfWeek, getQuarter, getWeek, getWeekdays - DateTime Mo…
RgnDunes Jan 18, 2024
a8087d5
add isAfter, isBefore, isLeapYear, isSameDay, isValidDate
RgnDunes Jan 18, 2024
e8fd26b
add getRelativeTime - DateTime Module
RgnDunes Jan 18, 2024
868db86
add parseDate, parseDateWithFormat, localeDateFormats - DateTime Module
RgnDunes Jan 18, 2024
87386cf
[fix]: syntax errors
RgnDunes Jan 18, 2024
661f50d
add dateTime module export
RgnDunes Jan 18, 2024
555f445
Create cuddly-eggs-design.md
RgnDunes Jan 18, 2024
31f8f7a
add locale check and state support for locale estimation
RgnDunes Jan 18, 2024
3770970
push build
RgnDunes Jan 18, 2024
2559974
update build
RgnDunes Jan 18, 2024
bbbebf5
remove build
RgnDunes Jan 18, 2024
14cdb79
add support for intlOptions
RgnDunes Jan 18, 2024
8df37a8
[fix]: eslint errors
RgnDunes Jan 18, 2024
499b653
Merge remote-tracking branch 'origin/master' into ATLAS-104-date-modu…
RgnDunes Jan 22, 2024
b819ee5
add parseDateTime
RgnDunes Jan 22, 2024
f2f36d0
add stringToDate desc in utils
RgnDunes Jan 22, 2024
1374936
migrated dateTime module to i18nify-js package
RgnDunes Jan 22, 2024
00ebcc6
refactor parseDateTime module
RgnDunes Jan 23, 2024
34f49b0
minor fixes
RgnDunes Jan 24, 2024
db96b5b
Merge remote-tracking branch 'origin/master' into ATLAS-104-date-modu…
RgnDunes Jan 24, 2024
ce8f59a
remove extra files
RgnDunes Jan 29, 2024
10fd174
[chore]: update date module api contracts
RgnDunes Feb 14, 2024
462add3
Merge remote-tracking branch 'origin/master' into ATLAS-104-date-modu…
RgnDunes Feb 14, 2024
da36410
[fix]: fix invalid parameter in formatDate
RgnDunes Feb 14, 2024
727a19f
[chore]: assign default empty object to intlOptions in parseDateTime
RgnDunes Feb 14, 2024
140f42e
docs[ATLAS-104]: Adding Documentation for Date & Time Module (#56)
RgnDunes Feb 14, 2024
e591663
test[ATLAS-104]: Adding Unit Tests for Date & Time Module (#55)
RgnDunes Feb 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add isAfter, isBefore, isLeapYear, isSameDay, isValidDate
  • Loading branch information
RgnDunes committed Jan 18, 2024
commit a8087d548a7e15ea8b83b0f71ca44392b72520ca
16 changes: 16 additions & 0 deletions src/modules/dateTime/isAfter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { withErrorBoundary } from '../../common/errorBoundary';
import { DateInput } from './types';

/**
* Compares two dates to determine if the first is after the second.
* @param {DateInput} date1 - First date object or date string.
* @param {DateInput} date2 - Second date object or date string.
* @returns {boolean} True if date1 is after date2.
*/
const isAfter = (date1: DateInput, date2: DateInput): boolean => {
const dateObj1: Date = date1 instanceof Date ? date1 : new Date(date1);
const dateObj2: Date = date2 instanceof Date ? date2 : new Date(date2);
return dateObj1 > dateObj2;
};

export default withErrorBoundary<typeof isAfter>(isAfter);
16 changes: 16 additions & 0 deletions src/modules/dateTime/isBefore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { withErrorBoundary } from '../../common/errorBoundary';
import { DateInput } from './types';

/**
* Compares two dates to determine if the first is before the second.
* @param {DateInput} date1 - First date object or date string.
* @param {DateInput} date2 - Second date object or date string.
* @returns {boolean} True if date1 is before date2.
*/
const isBefore = (date1: DateInput, date2: DateInput): boolean => {
const dateObj1: Date = date1 instanceof Date ? date1 : new Date(date1);
const dateObj2: Date = date2 instanceof Date ? date2 : new Date(date2);
return dateObj1 < dateObj2;
};

export default withErrorBoundary<typeof isBefore>(isBefore);
13 changes: 13 additions & 0 deletions src/modules/dateTime/isLeapYear.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { withErrorBoundary } from '../../common/errorBoundary';

/**
* Checks if a given year is a leap year.
*
* @param year The year to check.
* @returns True if the year is a leap year, false otherwise.
*/
const isLeapYear = (year: number): boolean => {
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
}

export default withErrorBoundary<typeof isLeapYear>(isLeapYear);
18 changes: 18 additions & 0 deletions src/modules/dateTime/isSameDay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { withErrorBoundary } from '../../common/errorBoundary';

/**
* Checks if two dates fall on the same day.
*
* @param date1 The first date.
* @param date2 The second date.
* @returns True if both dates are on the same day, false otherwise.
*/
const isSameDay = (date1: Date, date2: Date): boolean => {
return (
date1.getDate() === date2.getDate() &&
date1.getMonth() === date2.getMonth() &&
date1.getFullYear() === date2.getFullYear()
);
}

export default withErrorBoundary<typeof isSameDay>(isSameDay);
13 changes: 13 additions & 0 deletions src/modules/dateTime/isValidDate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { withErrorBoundary } from '../../common/errorBoundary';

/**
* Checks if a given object is a valid Date object.
*
* @param date The object to check.
* @returns True if the object is a valid Date, false otherwise.
*/
const isValidDate = (date: any): boolean => {
return date instanceof Date && !isNaN(date.getTime());
}

export default withErrorBoundary<typeof isValidDate>(isValidDate);