Implement auto switcher for light and dark theme (#388)
Remove import and add author Implement auto switcher for light and dark theme. other ui fixes Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/388 Reviewed-by: 6543 <6543@noreply.gitea.io>
This commit is contained in:
@@ -6,9 +6,14 @@ import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class TimeHelper {
|
||||
|
||||
public static String customDateFormatForToast(String customDate) {
|
||||
@@ -59,4 +64,29 @@ public class TimeHelper {
|
||||
|
||||
}
|
||||
|
||||
public static boolean timeBetweenHours(int fromHour, int toHour) {
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
Calendar from = Calendar.getInstance();
|
||||
from.set(Calendar.HOUR_OF_DAY, fromHour);
|
||||
from.set(Calendar.MINUTE, 0);
|
||||
|
||||
Calendar to = Calendar.getInstance();
|
||||
to.set(Calendar.HOUR_OF_DAY, toHour);
|
||||
to.set(Calendar.MINUTE, 0);
|
||||
|
||||
if(to.before(from)) {
|
||||
if (cal.after(to)) {
|
||||
to.add(Calendar.DATE, 1);
|
||||
}
|
||||
else {
|
||||
from.add(Calendar.DATE, -1);
|
||||
}
|
||||
}
|
||||
|
||||
return cal.after(from) && cal.before(to);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user