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:
M M Arif
2020-04-11 06:06:39 +00:00
parent 79944241fe
commit f5d5264ef7
6 changed files with 50 additions and 6 deletions

View File

@@ -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);
}
}