github.com/go-chrono/chrono@v0.0.0-20240102183611-532f0d0d7c34/consts.go (about)

     1  package chrono
     2  
     3  import "fmt"
     4  
     5  // Weekday specifies the day of the week (Monday = 0, ...).
     6  // Not compatible standard library's time.Weekday (in which Sunday = 0, ...).
     7  type Weekday int
     8  
     9  // The days of the week.
    10  const (
    11  	Monday Weekday = iota + 1
    12  	Tuesday
    13  	Wednesday
    14  	Thursday
    15  	Friday
    16  	Saturday
    17  	Sunday
    18  )
    19  
    20  func (d Weekday) String() string {
    21  	return longWeekdayName(int(d))
    22  }
    23  
    24  func longWeekdayName(d int) string {
    25  	if d < int(Monday) || d > int(Sunday) {
    26  		return fmt.Sprintf("%%!Weekday(%d)", d)
    27  	}
    28  	return longDayNames[d-1]
    29  }
    30  
    31  var longDayNames = [7]string{
    32  	Monday - 1:    "Monday",
    33  	Tuesday - 1:   "Tuesday",
    34  	Wednesday - 1: "Wednesday",
    35  	Thursday - 1:  "Thursday",
    36  	Friday - 1:    "Friday",
    37  	Saturday - 1:  "Saturday",
    38  	Sunday - 1:    "Sunday",
    39  }
    40  
    41  // Month specifies the month of the year (January = 1, ...).
    42  type Month int
    43  
    44  // The months of the year.
    45  const (
    46  	January Month = iota + 1
    47  	February
    48  	March
    49  	April
    50  	May
    51  	June
    52  	July
    53  	August
    54  	September
    55  	October
    56  	November
    57  	December
    58  )
    59  
    60  func (m Month) String() string {
    61  	return longMonthName(int(m))
    62  }
    63  
    64  func longMonthName(m int) string {
    65  	if m < int(January) || m > int(December) {
    66  		return fmt.Sprintf("%%!Month(%d)", m)
    67  	}
    68  	return longMonthNames[m-1]
    69  }
    70  
    71  var longMonthNames = [12]string{
    72  	January - 1:   "January",
    73  	February - 1:  "February",
    74  	March - 1:     "March",
    75  	April - 1:     "April",
    76  	May - 1:       "May",
    77  	June - 1:      "June",
    78  	July - 1:      "July",
    79  	August - 1:    "August",
    80  	September - 1: "September",
    81  	October - 1:   "October",
    82  	November - 1:  "November",
    83  	December - 1:  "December",
    84  }