Skip to content

Commit 395a746

Browse files
authored
major bug fixed
1 parent 4a2ca0c commit 395a746

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/com/sbiswas001/twelveproject/DateRepresentation.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,11 @@ private void oldDateCalculator() {
107107
monthDays[1] = 29;
108108

109109
oldDate = days;
110-
int i = 0;
111-
while(oldDate > monthDays[i]) {
112-
oldDate -= monthDays[i];
113-
monthIndex = i + 1;
114-
i++;
115-
if (i == 12) {
116-
i = 0;
110+
while(oldDate > monthDays[monthIndex]) {
111+
oldDate -= monthDays[monthIndex];
112+
monthIndex ++;
113+
if (monthIndex == 12) {
114+
monthIndex = 0;
117115
year++;
118116
if (year % 400 == 0 ||
119117
(year % 100 != 0 && year % 4 == 0)) {
@@ -140,13 +138,11 @@ private void oldDateCalculator() {
140138
private void newDateCalculator() {
141139
//Calculating date after n days
142140
daysAfter = oldDate + increment;
143-
int i = 0;
144-
while(daysAfter > monthDays[i]) {
145-
daysAfter -= monthDays[i];
146-
monthIndex = i + 1;
147-
i++;
148-
if (i == 12) {
149-
i = 0;
141+
while(daysAfter > monthDays[monthIndex]) {
142+
daysAfter -= monthDays[monthIndex];
143+
monthIndex ++;
144+
if (monthIndex == 12) {
145+
monthIndex = 0;
150146
year++;
151147
if (year % 400 == 0 ||
152148
(year % 100 != 0 && year % 4 == 0)) {

0 commit comments

Comments
 (0)