From d463a25251b2f51ce4c6d50d9df19eb3a5e42469 Mon Sep 17 00:00:00 2001 From: Saman Date: Fri, 8 Sep 2023 16:57:56 +0330 Subject: [PATCH] Solved reported bug [#81] - Add new add/subs methods --- README.md | 10 +- app/build.gradle | 4 +- persiandate/gitpack.gradle | 2 +- .../saman/zamani/persiandate/PersianDate.java | 212 ++++++++++------- .../zamani/persiandate/PersianDateTest.java | 224 +++++++++++++++++- 5 files changed, 357 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index 5d70a46..41640c5 100755 --- a/README.md +++ b/README.md @@ -21,11 +21,17 @@ allprojects { Step 2.Add the dependency ```groovy dependencies { - implementation 'com.github.samanzamani:PersianDate:1.6.1' + implementation 'com.github.samanzamani:PersianDate:1.7.0' } ``` # what's new +### version 1.7.0 +* Fix add/sub reported bug (Reported By [@Alireza-Jamali](https://github.com/Alireza-Jamali)). [#81](https://github.com/samanzamani/PersianDate/issues/81) +* Add new adds methods: `addWeeks`,`addDays`,`addMonths`,`addYears`,`addHours`,`addMinutes`,.... +* Add new subs methods: `subsWeeks`,`subsDays`,`subsMonths`,`subsYears`,`subsHours`,`subsMinutes`,.... +* Increase test coverage. + ### version 1.6.1 * Add validation for set methods and Init methods (Reported By [@ahmad-shoja](https://github.com/ahmad-shoja)). [#77](https://github.com/samanzamani/PersianDate/pull/77) * Add `isToday` method suggested by [AlirezaGhanbarinia](https://github.com/AlirezaGhanbarinia). [#75](https://github.com/samanzamani/PersianDate/pull/75) @@ -37,8 +43,6 @@ dependencies { ### version 1.5.4 * Correction `H` and `g` keywords in `PersianDateFormat` class. [#71](https://github.com/samanzamani/PersianDate/pull/71) -### version 1.5.2 -* Change type of add* function arguments from `long` to `int` [#68](https://github.com/samanzamani/PersianDate/pull/68) ## Let's convert some date :) diff --git a/app/build.gradle b/app/build.gradle index 3082728..44e4caf 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "saman.zamani.persiandatedemo" minSdkVersion 17 targetSdkVersion 33 - versionCode 1 - versionName "1.0" + versionCode 170 + versionName "1.7.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/persiandate/gitpack.gradle b/persiandate/gitpack.gradle index bcec291..24b9449 100755 --- a/persiandate/gitpack.gradle +++ b/persiandate/gitpack.gradle @@ -5,7 +5,7 @@ afterEvaluate { from components.release groupId = 'com.github.samanzamani.persiandate' artifactId = 'stable' - version = '1.3.1' + version = '1.7.0' } } } diff --git a/persiandate/src/main/java/saman/zamani/persiandate/PersianDate.java b/persiandate/src/main/java/saman/zamani/persiandate/PersianDate.java index 72fc912..2e64842 100755 --- a/persiandate/src/main/java/saman/zamani/persiandate/PersianDate.java +++ b/persiandate/src/main/java/saman/zamani/persiandate/PersianDate.java @@ -11,7 +11,6 @@ /** * Created by Saman Zamani(saman.zamani1@gmail.com) on 3/31/2017 AD. - * * Last update on Friday, July 15, 2022 */ public class PersianDate { @@ -124,6 +123,7 @@ public PersianDate setLocal(Locale locale) { public Dialect getDialect() { return dialect; } + public PersianDate setDialect(Dialect dialect) { this.dialect = dialect; return this; @@ -140,7 +140,7 @@ public int getShYear() { * @return PersianDate * @throws IllegalArgumentException Return Exception if Year is less than 1 */ - public PersianDate setShYear(int shYear) throws IllegalArgumentException{ + public PersianDate setShYear(int shYear) throws IllegalArgumentException { if (shYear < 1) { throw new IllegalArgumentException("PersianDate Error: ##=> Year must be greater than 0"); } @@ -160,7 +160,7 @@ public int getShMonth() { * @return PersianDate * @throws IllegalArgumentException Return Exception if Month is less than 1 or greater than 12 */ - public PersianDate setShMonth(int shMonth) throws IllegalArgumentException{ + public PersianDate setShMonth(int shMonth) throws IllegalArgumentException { if (shMonth < 1 || shMonth > 12) { throw new IllegalArgumentException("PersianDate Error: ##=> Month must be between 1 and 12"); } @@ -178,9 +178,10 @@ public int getShDay() { * * @param shDay Shamsi Day as a Integer value between 1 and 29~31 * @return PersianDate object - * @throws IllegalArgumentException Return Exception if Day is less than 1 or greater than 29~31 (Depend on Month Length) + * @throws IllegalArgumentException Return Exception if Day is less than 1 or greater than 29~31 + * (Depend on Month Length) */ - public PersianDate setShDay(int shDay) throws IllegalArgumentException{ + public PersianDate setShDay(int shDay) throws IllegalArgumentException { if (shDay < 1 || shDay > 31) { throw new IllegalArgumentException("PersianDate Error: ##=> Day must be between 1 and 29~31"); } @@ -205,7 +206,7 @@ public int getGrgYear() { * @return PersianDate * @throws IllegalArgumentException Return Exception if Year is less than 1 */ - public PersianDate setGrgYear(int grgYear) throws IllegalArgumentException{ + public PersianDate setGrgYear(int grgYear) throws IllegalArgumentException { if (grgYear < 1) { throw new IllegalArgumentException("PersianDate Error: ##=> Year must be greater than 0"); } @@ -225,7 +226,7 @@ public int getGrgMonth() { * @return PersianDate * @throws IllegalArgumentException Return Exception if Month is less than 1 or greater than 12 */ - public PersianDate setGrgMonth(int grgMonth) throws IllegalArgumentException{ + public PersianDate setGrgMonth(int grgMonth) throws IllegalArgumentException { if (grgMonth < 1 || grgMonth > 12) { throw new IllegalArgumentException("PersianDate Error: ##=> Month must be between 1 and 12"); } @@ -243,9 +244,10 @@ public int getGrgDay() { * * @param grgDay Gregorian Day as a Integer value between 1 and 28~31 * @return PersianDate object - * @throws IllegalArgumentException Return Exception if Day is less than 1 or greater than 28~31 (Depend on Month Length) + * @throws IllegalArgumentException Return Exception if Day is less than 1 or greater than 28~31 + * (Depend on Month Length) */ - public PersianDate setGrgDay(int grgDay) throws IllegalArgumentException{ + public PersianDate setGrgDay(int grgDay) throws IllegalArgumentException { if (grgDay < 1 || grgDay > 31) { throw new IllegalArgumentException("PersianDate Error: ##=> Day must be between 1 and 28~31"); } @@ -274,13 +276,13 @@ public int get12FormatHour() { /** * Set Minute * - * * @param hour Hour as a integer number between 0 and 23 * @return PersianDate object - * @throws IllegalArgumentException Returns an IllegalArgumentException if hour is not between 0 and 23 + * @throws IllegalArgumentException Returns an IllegalArgumentException if hour is not between 0 + * and 23 */ - public PersianDate setHour(int hour) throws IllegalArgumentException{ - if(hour < 0 || hour > 23){ + public PersianDate setHour(int hour) throws IllegalArgumentException { + if (hour < 0 || hour > 23) { throw new IllegalArgumentException("PersianDate Error: ##=> Hour must be between 0 and 23"); } this.hour = hour; @@ -295,13 +297,13 @@ public int getMinute() { /** * Set Minute * - * * @param minute Minute as a integer number between 0 and 59 * @return PersianDate object - * @throws IllegalArgumentException Returns an IllegalArgumentException if second is not between 0 and 59 + * @throws IllegalArgumentException Returns an IllegalArgumentException if second is not between 0 + * and 59 */ public PersianDate setMinute(int minute) throws IllegalArgumentException { - if(minute < 0 || minute > 59){ + if (minute < 0 || minute > 59) { throw new IllegalArgumentException("PersianDate Error: ##=> Minute must be between 0 and 59"); } this.minute = minute; @@ -316,13 +318,13 @@ public int getSecond() { /** * Set Second * - * * @param second Second as a integer number between 0 and 59 * @return PersianDate object - * @throws IllegalArgumentException Returns an IllegalArgumentException if second is not between 0 and 59 + * @throws IllegalArgumentException Returns an IllegalArgumentException if second is not between 0 + * and 59 */ - public PersianDate setSecond(int second) throws IllegalArgumentException{ - if(second < 0 || second > 59){ + public PersianDate setSecond(int second) throws IllegalArgumentException { + if (second < 0 || second > 59) { throw new IllegalArgumentException("PersianDate Error: ##=> Second must be between 0 and 59"); } this.second = second; @@ -338,7 +340,7 @@ public PersianDate setSecond(int second) throws IllegalArgumentException{ * @param day Day in Grg * @return persianDate */ - public PersianDate initGrgDate(int year, int month, int day) throws IllegalArgumentException{ + public PersianDate initGrgDate(int year, int month, int day) throws IllegalArgumentException { return this.initGrgDate(year, month, day, 0, 0, 0); } @@ -353,7 +355,8 @@ public PersianDate initGrgDate(int year, int month, int day) throws IllegalArgum * @param second second * @return PersianDate */ - public PersianDate initGrgDate(int year, int month, int day, int hour, int minute, int second) throws IllegalArgumentException{ + public PersianDate initGrgDate(int year, int month, int day, int hour, int minute, int second) + throws IllegalArgumentException { //check input parameter if (year < 1) { throw new IllegalArgumentException("PersianDate Error: ##=> Year must be greater than 0"); @@ -375,7 +378,8 @@ public PersianDate initGrgDate(int year, int month, int day, int hour, int minut } if (day > this.getGrgMonthLength(year, month)) { throw new IllegalArgumentException( - "PersianDate Error: ##=> Day in the " + this.getGrgMonthName(month) + " must be between 1 and " + "PersianDate Error: ##=> Day in the " + this.getGrgMonthName(month) + + " must be between 1 and " + this.getGrgMonthLength(year, month)); } this.grgYear = year; @@ -396,7 +400,7 @@ public PersianDate initGrgDate(int year, int month, int day, int hour, int minut * @param day day in Jallali date * @return PersianDate */ - public PersianDate initJalaliDate(int year, int month, int day) throws IllegalArgumentException{ + public PersianDate initJalaliDate(int year, int month, int day) throws IllegalArgumentException { return this.initJalaliDate(year, month, day, 0, 0, 0); } @@ -412,7 +416,7 @@ public PersianDate initJalaliDate(int year, int month, int day) throws IllegalAr * @return PersianDate */ public PersianDate initJalaliDate(int year, int month, int day, int hour, int minute, - int second) throws IllegalArgumentException{ + int second) throws IllegalArgumentException { //validate input parameters if (year < 1) { throw new IllegalArgumentException("PersianDate Error: ##=> Year must be greater than 0"); @@ -652,7 +656,7 @@ public ArrayList getWeek(PersianDate date) { int threshold = (7 - currentWeek.size()); for (int j = 1; j <= threshold; j++) { PersianDate dateTmp = new PersianDate(date.timeInMilliSecond); - currentWeek.add(dateTmp.addDay(j)); + currentWeek.add(dateTmp.addDays(j)); } return currentWeek; } @@ -710,6 +714,7 @@ public String monthName(int month, Dialect dialect) { return this.monthNames[month - 1]; } } + /** * return month name * @@ -722,6 +727,7 @@ public String monthName(Dialect dialect) { public String monthName(int shMonth) { return monthName(shMonth, this.getDialect()); } + /** * Get current month name in Persian */ @@ -887,37 +893,28 @@ public int getDayInYear(int month, int day) { */ public PersianDate subDate(long SubYear, long SubMonth, long SubDay, long SubHour, long SubMinute, long SubSecond) { - //sub Days - long dayMustDecrease = SubDay; - //check if month bigger than a year - if (SubMonth >= 12) { - SubYear += (int) Math.floor(SubMonth / 12.0); - SubMonth = (SubMonth % 12); + Calendar cal = Calendar.getInstance(); + //add day to cal + cal.setTime(this.toDate()); + if (SubYear >= 1) { + cal.add(Calendar.YEAR, (int) -SubYear); } - //sub year - for (int i = 1; i <= SubYear; i++) { - if (this.isLeap((this.shYear - i))) { - dayMustDecrease += 366; - } else { - dayMustDecrease += 365; - } + if (SubMonth >= 1) { + cal.add(Calendar.MONTH, (int) -SubMonth); } - - //sub month - int tmpYear = this.shYear - (int) SubYear; - int tmpMonth = this.shMonth; - for (int i = 0; i < SubMonth; i++) { - tmpMonth -= 1; - if (tmpMonth <= 0) { - tmpYear -= 1; - tmpMonth = 12; - } - dayMustDecrease += this.getMonthLength(tmpYear, tmpMonth); + if (SubDay >= 1) { + cal.add(Calendar.DAY_OF_MONTH, (int) -SubDay); } - - this.timeInMilliSecond -= - ((dayMustDecrease * 86_400_000L) + (SubHour * 3_600_000) + (SubMinute * 60_000) + (SubSecond - * 1_000)); + if (SubHour >= 1) { + cal.add(Calendar.HOUR_OF_DAY, (int) -SubHour); + } + if (SubMinute >= 1) { + cal.add(Calendar.MINUTE, (int) -SubMinute); + } + if (SubSecond >= 1) { + cal.add(Calendar.SECOND, (int) -SubSecond); + } + this.timeInMilliSecond = cal.getTimeInMillis(); this.init(); return this; } @@ -1048,6 +1045,14 @@ public PersianDate subSecond() { return this.subSeconds(1); } + public PersianDate subWeeks(int weeks) { + return this.subDays(7*weeks); + } + + public PersianDate subWeek() { + return this.subWeeks(1); + } + /** * add date * @@ -1060,36 +1065,30 @@ public PersianDate subSecond() { * @return new date */ public PersianDate addDate(long AddYear, long AddMonth, long AddDay, long AddHour, long AddMinute, - long AddSecond) { - //add Days - long dayMustIncrease = AddDay; - //check if month bigger than a year - if (AddMonth >= 12) { - AddYear += (int) Math.floor(AddMonth / 12.0); - AddMonth = (AddMonth % 12); + long AddSecond) throws IllegalArgumentException{ + Calendar cal = Calendar.getInstance(); + //add day to cal + cal.setTime(this.toDate()); + if (AddYear >= 1) { + cal.add(Calendar.YEAR, (int) AddYear); } - //add year - for (int i = 0; i < AddYear; i++) { - if (this.isLeap((this.shYear + i))) { - dayMustIncrease += 366; - } else { - dayMustIncrease += 365; - } + if (AddMonth >= 1) { + cal.add(Calendar.MONTH, (int) AddMonth); } - //add month - int tmpYear = this.shYear - (int) AddYear; - int tmpMonth = this.shMonth; - for (int i = 0; i < AddMonth; i++) { - dayMustIncrease += this.getMonthLength(tmpYear, tmpMonth); - tmpMonth += 1; - if (tmpMonth >= 13) { - tmpYear += 1; - tmpMonth = 1; - } + if (AddDay >= 1) { + cal.add(Calendar.DAY_OF_MONTH, (int) AddDay); + } + if (AddHour >= 1) { + cal.add(Calendar.HOUR_OF_DAY, (int) AddHour); } - this.timeInMilliSecond += - ((dayMustIncrease * 86_400_000L) + (AddHour * 3_600_000) + (AddMinute * 60_000) + (AddSecond - * 1_000)); + if (AddMinute >= 1) { + cal.add(Calendar.MINUTE, (int) AddMinute); + } + if (AddSecond >= 1) { + cal.add(Calendar.SECOND, (int) AddSecond); + } + + this.timeInMilliSecond = cal.getTimeInMillis(); this.init(); return this; } @@ -1105,22 +1104,59 @@ public PersianDate addDate(long year, long month, long day) { return this.addDate(year, month, day, 0, 0, 0); } - public PersianDate addYear(int year) { + public PersianDate addYear() { + return this.addYears(1); + } + public PersianDate addYears(int year) { return this.addDate(year, 0, 0); } - public PersianDate addMonth(int month) { + public PersianDate addMonth() { + return this.addMonths(1); + } + public PersianDate addMonths(int month) { return this.addDate(0, month, 0); } - public PersianDate addWeek(int week) { - return this.addDate(0, 0, (week * 7L)); + public PersianDate addWeek() { + return this.addWeeks(1); + } + public PersianDate addWeeks(int week) { + return this.addDays(7*week); + } + + public PersianDate addDay() { + return this.addDays(1); } - public PersianDate addDay(int day) { + public PersianDate addDays(int day) { return this.addDate(0, 0, day); } + public PersianDate addHour() { + return this.addHours(1); + } + + public PersianDate addHours(int hour) { + return this.addDate(0, 0, 0, hour, 0, 0); + } + + public PersianDate addMinute() { + return this.addMinutes(1); + } + + public PersianDate addMinutes(int minute) { + return this.addDate(0, 0, 0, 0, minute, 0); + } + + public PersianDate addSecond() { + return this.addSeconds(1); + } + + public PersianDate addSeconds(int second) { + return this.addDate(0, 0, 0, 0, 0, second); + } + /** * Compare 2 date * @@ -1243,7 +1279,7 @@ public static PersianDate today() { */ public static PersianDate tomorrow() { PersianDate persianDate = new PersianDate(); - persianDate.addDay(1); + persianDate.addDay(); persianDate.setHour(0).setMinute(0).setSecond(0); return persianDate; } @@ -1320,7 +1356,7 @@ public String getTimeOfTheDay(PersianDate persianDate) { return (persianDate.isMidNight()) ? AM_NAME : PM_NAME; } - public int getGrgMonthLength(int grgYear,int grgMonth) { + public int getGrgMonthLength(int grgYear, int grgMonth) { Calendar cal = Calendar.getInstance(); //set year in cal object cal.set(Calendar.YEAR, grgYear); diff --git a/persiandate/src/test/java/saman/zamani/persiandate/PersianDateTest.java b/persiandate/src/test/java/saman/zamani/persiandate/PersianDateTest.java index df457ba..266e63b 100644 --- a/persiandate/src/test/java/saman/zamani/persiandate/PersianDateTest.java +++ b/persiandate/src/test/java/saman/zamani/persiandate/PersianDateTest.java @@ -107,7 +107,7 @@ public void testTimestamp() throws Exception { public void testIsTodayMethodWithoutParameter() throws Exception { PersianDate pDate = new PersianDate(); assertTrue(pDate.isToday()); - assertFalse(pDate.addDay(1).isToday()); + assertFalse(pDate.addDay().isToday()); } @Test public void testIsTodayMethodWithParameter() throws Exception { @@ -441,4 +441,226 @@ public void testInitJalaliDateWithInvalidSecond() throws Exception { pDate.initJalaliDate(1399,1,1,23,59,60); } + //test add dates methods + @Test + public void testAddDay() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setShDay(1); + pDate.addDay(); + assertEquals(2, pDate.getShDay()); + } + + @Test + public void testAddDayWithParameter() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setShDay(1); + pDate.addDays(2); + assertEquals(3, pDate.getShDay()); + } + + @Test + public void testAddMonth() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setShMonth(1); + pDate.addMonth(); + assertEquals(2, pDate.getShMonth()); + } + + @Test + public void testAddMonthWithParameter() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setShMonth(1); + pDate.addMonths(2); + assertEquals(3, pDate.getShMonth()); + } + + @Test + public void testAddYear() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setShYear(1399); + pDate.addYear(); + assertEquals(1400, pDate.getShYear()); + } + + @Test + public void testAddYearWithParameter() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setShYear(1399); + pDate.addYears(2); + assertEquals(1401, pDate.getShYear()); + } + + @Test + public void testAddHour() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setHour(1); + pDate.addHour(); + assertEquals(2, pDate.getHour()); + } + + @Test + public void testAddHourWithParameter() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setHour(1); + pDate.addHours(2); + assertEquals(3, pDate.getHour()); + } + + @Test + public void testAddMinute() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setMinute(1); + pDate.addMinute(); + assertEquals(2, pDate.getMinute()); + } + + @Test + public void testAddMinuteWithParameter() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setMinute(1); + pDate.addMinutes(2); + assertEquals(3, pDate.getMinute()); + } + + @Test + public void testAddSecond() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setSecond(1); + pDate.addSecond(); + assertEquals(2, pDate.getSecond()); + } + + @Test + public void testAddSecondWithParameter() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setSecond(1); + pDate.addSeconds(2); + assertEquals(3, pDate.getSecond()); + } + + @Test + public void testAddWeek() throws Exception { + PersianDate pDate = new PersianDate().initJalaliDate(1399,1,1); + pDate.addWeek(); + assertEquals(8, pDate.getShDay()); + } + + @Test + public void testAddWeekWithParameter() throws Exception { + PersianDate pDate = new PersianDate().initJalaliDate(1399,1,1); + pDate.addWeeks(3); + assertEquals(22, pDate.getShDay()); + } + + //test sub dates + @Test + public void testSubDay() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setShDay(3); + pDate.subDay(); + assertEquals(2, pDate.getShDay()); + } + + @Test + public void testSubDayWithParameter() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setShDay(3); + pDate.subDays(2); + assertEquals(1, pDate.getShDay()); + } + + @Test + public void testSubMonth() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setShMonth(3); + pDate.subMonth(); + assertEquals(2, pDate.getShMonth()); + } + + @Test + public void testSubMonthWithParameter() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setShMonth(3); + pDate.subMonths(2); + assertEquals(1, pDate.getShMonth()); + } + + @Test + public void testSubYear() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setShYear(1399); + pDate.subYear(); + assertEquals(1398, pDate.getShYear()); + } + + @Test + public void testSubYearWithParameter() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setShYear(1399); + pDate.subYears(2); + assertEquals(1397, pDate.getShYear()); + } + + @Test + public void testSubHour() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setHour(3); + pDate.subHour(); + assertEquals(2, pDate.getHour()); + } + + @Test + public void testSubHourWithParameter() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setHour(3); + pDate.subHours(2); + assertEquals(1, pDate.getHour()); + } + + @Test + public void testSubMinute() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setMinute(3); + pDate.subMinute(); + assertEquals(2, pDate.getMinute()); + } + + @Test + public void testSubMinuteWithParameter() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setMinute(3); + pDate.subMinutes(2); + assertEquals(1, pDate.getMinute()); + } + + @Test + public void testSubSecond() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setSecond(3); + pDate.subSecond(); + assertEquals(2, pDate.getSecond()); + } + + @Test + public void testSubSecondWithParameter() throws Exception { + PersianDate pDate = new PersianDate(); + pDate.setSecond(3); + pDate.subSeconds(2); + assertEquals(1, pDate.getSecond()); + } + + @Test + public void testSubWeek() throws Exception { + PersianDate pDate = new PersianDate().initJalaliDate(1399,1,8); + pDate.subWeek(); + assertEquals(1, pDate.getShDay()); + } + + @Test + public void testSubWeekWithParameter() throws Exception { + PersianDate pDate = new PersianDate().initJalaliDate(1399,1,22); + pDate.subWeeks(3); + assertEquals(1, pDate.getShDay()); + } + }