7 examples of 'month.days' in Go

Every line of 'month.days' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
292func daysInMonth(month time.Month, year int) int {
293 if month == time.December {
294 return 31
295 }
296
297 date := time.Date(year, month+time.Month(1), 1, 0, 0, 0, 0, time.Local)
298 return date.Add(-1 * day).Day()
299}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

50func (g *Goment) DaysInMonth() int {
51 return daysInMonth(g.Month(), g.Year())
52}
166func (kt *LkkTime) GetMonthDays(month int, year ...int) (days int) {
167 if month < 1 || month > 12 {
168 return
169 }
170
171 var yr int
172 if len(year) == 0 {
173 yr = time.Now().Year()
174 } else {
175 yr = year[0]
176 }
177
178 if month != 2 {
179 if month == 4 || month == 6 || month == 9 || month == 11 {
180 days = 30
181 } else {
182 days = 31
183 }
184 } else {
185 if ((yr%4) == 0 && (yr%100) != 0) || (yr%400) == 0 {
186 days = 29
187 } else {
188 days = 28
189 }
190 }
191
192 return
193}
284func diffDays(date1, date2 time.Time) int64 {
285 return int64(date2.Sub(date1) / (24 * time.Hour))
286}
232func (c Carbon) SubDays(days int) Carbon {
233 return c.AddDays(-days)
234}
5func dayOfTheWeek(day int, month int, year int) string {
6 return time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.Local).Weekday().String()
7}
40func numDaysInYear(year int) int {
41 // Invariant: year always in bounds.
42 daysDistribution, _ := bsDaysInMonthsByYear[year]
43
44 sum := 0
45 for _, value := range daysDistribution {
46 sum += value
47 }
48
49 return sum
50}

Related snippets