Skip to content

Commit af1112e

Browse files
committed
1th month 2th month swipe crash on hijri and gre fixed
1 parent 1136d72 commit af1112e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/src/main/java/com/ali/universaldatetools/MainActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected void onCreate(Bundle savedInstanceState) {
2626
Button getTime = findViewById(R.id.btn_get_time);
2727
TextView timeView = findViewById(R.id.text_time_show);
2828

29-
a.ShowDatePicker(Calendar.Jalali);
29+
a.ShowDatePicker(Calendar.Gregorian);
3030
a.setOnDateSelected((dateSystem, unixTime) -> {
3131
timeView.setText("unix time is: " + unixTime);
3232
timeView.append("\ndate is: " + dateSystem);
@@ -41,6 +41,7 @@ protected void onCreate(Bundle savedInstanceState) {
4141
}
4242
});
4343

44+
4445
lang.setOnClickListener(v -> {
4546
if (getString(R.string.LangId).equals("en")) {
4647
setLocale("fa");

uneversaldatetools/src/main/java/com/ali/uneversaldatetools/date/DateSystem.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.support.annotation.NonNull;
55
import android.support.annotation.Nullable;
66
import android.support.annotation.RequiresApi;
7+
import android.util.Log;
78

89
import com.ali.uneversaldatetools.model.DateModel;
910
import com.ali.uneversaldatetools.tools.DateTools;
@@ -50,7 +51,10 @@ public DateSystem(DateModel date, Calendar calendar) {
5051
public DateSystem(int year, int month, int day, Calendar calendar) {
5152
Calendar = calendar;
5253

53-
if (month == 0) throw new IllegalArgumentException("month cant be 0");
54+
Log.d("month: ", String.valueOf(month));
55+
if (month > 12) month -= 12;
56+
else if (month < 1) month += 12;
57+
5458
switch (Calendar) {
5559
case Jalali: {
5660
Date_SD = new JalaliDateTime(year, month, day);
@@ -68,7 +72,6 @@ public DateSystem(int year, int month, int day, Calendar calendar) {
6872
throw new RuntimeException("Invalid Calendar Type!");
6973
}
7074
}
71-
7275
Date = Date_SD.getDate();
7376
}
7477

0 commit comments

Comments
 (0)