|
|
|
@ -79,6 +79,14 @@ fun Date.getDayNumber() : String { |
|
|
|
fun Date.getShortDayName() : String { |
|
|
|
fun Date.getShortDayName() : String { |
|
|
|
return SimpleDateFormat("EEE", Locale.getDefault()).format(this) |
|
|
|
return SimpleDateFormat("EEE", Locale.getDefault()).format(this) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Return the month of the date |
|
|
|
|
|
|
|
fun Date.getDateMonth(): String { |
|
|
|
|
|
|
|
return SimpleDateFormat("MMMM", Locale.getDefault()).format(this).capitalize() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Return the year of the date |
|
|
|
|
|
|
|
fun Date.getDateYear(): String { |
|
|
|
|
|
|
|
return SimpleDateFormat("yyyy", Locale.getDefault()).format(this).capitalize() |
|
|
|
|
|
|
|
} |
|
|
|
// Return the month & year of the date |
|
|
|
// Return the month & year of the date |
|
|
|
fun Date.getMonthAndYear(): String { |
|
|
|
fun Date.getMonthAndYear(): String { |
|
|
|
return SimpleDateFormat("MMMM yyyy", Locale.getDefault()).format(this).capitalize() |
|
|
|
return SimpleDateFormat("MMMM yyyy", Locale.getDefault()).format(this).capitalize() |
|
|
|
@ -118,3 +126,19 @@ fun Date.endOfDay() : Date { |
|
|
|
calendar.set(Calendar.MILLISECOND, 999) |
|
|
|
calendar.set(Calendar.MILLISECOND, 999) |
|
|
|
return calendar.time |
|
|
|
return calendar.time |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Return the date of the beginning of the current month |
|
|
|
|
|
|
|
fun Date.startOfMonth() : Date { |
|
|
|
|
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
|
|
|
|
calendar.time = this.startOfDay() |
|
|
|
|
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, 1) |
|
|
|
|
|
|
|
return calendar.time |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Return the date of the beginning of the current year |
|
|
|
|
|
|
|
fun Date.startOfYear() : Date { |
|
|
|
|
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
|
|
|
|
calendar.time = this.startOfMonth() |
|
|
|
|
|
|
|
calendar.set(Calendar.MONTH, 0) |
|
|
|
|
|
|
|
return calendar.time |
|
|
|
|
|
|
|
} |