/
BaseCalendar.kt
61 lines (38 loc) · 1.74 KB
/
BaseCalendar.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.aminography.primecalendar.base
import com.aminography.primecalendar.common.IConverter
import java.util.*
/**
* @author aminography
*/
abstract class BaseCalendar : GregorianCalendar, IConverter {
abstract val year: Int
abstract val month: Int
abstract val dayOfMonth: Int
abstract val monthName: String
abstract val weekDayName: String
abstract val monthLength: Int
abstract val isLeapYear: Boolean
val longDateString: String
get() = "$weekDayName, $dayOfMonth $monthName $year"
@Suppress("MemberVisibilityCanBePrivate")
val shortDateString: String
get() = normalize(year) + delimiter + normalize(month) + delimiter + normalize(dayOfMonth)
@Suppress("unused")
val monthDayString: String
get() = monthName + " " + normalize(dayOfMonth)
open fun setDate(year: Int, month: Int, dayOfMonth: Int) {
set(year, month, dayOfMonth)
}
override fun toString(): String {
val s = super.toString()
return "${s.substring(0, s.length - 1)}, Date=$shortDateString]"
}
// ---------------------------------------------------------------------------------------------
constructor() : super()
constructor(zone: TimeZone) : super(zone)
constructor(aLocale: Locale) : super(aLocale)
constructor(zone: TimeZone, aLocale: Locale) : super(zone, aLocale)
constructor(year: Int, month: Int, dayOfMonth: Int) : super(year, month, dayOfMonth)
constructor(year: Int, month: Int, dayOfMonth: Int, hourOfDay: Int, minute: Int) : super(year, month, dayOfMonth, hourOfDay, minute)
constructor(year: Int, month: Int, dayOfMonth: Int, hourOfDay: Int, minute: Int, second: Int) : super(year, month, dayOfMonth, hourOfDay, minute, second)
}