MCPcopy Index your code
hub / github.com/pydata/xarray / YearBegin

Class YearBegin

xarray/coding/cftime_offsets.py:562–584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

560
561
562class YearBegin(YearOffset):
563 _freq = "YS"
564 _day_option = "start"
565 _default_month = 1
566
567 def onOffset(self, date) -> bool:
568 """Check if the given date is in the set of possible dates created
569 using a length-one version of this offset class."""
570 return date.day == 1 and date.month == self.month
571
572 def rollforward(self, date):
573 """Roll date forward to nearest start of year"""
574 if self.onOffset(date):
575 return date
576 else:
577 return date + YearBegin(month=self.month)
578
579 def rollback(self, date):
580 """Roll date backward to nearest start of year"""
581 if self.onOffset(date):
582 return date
583 else:
584 return date - YearBegin(month=self.month)
585
586
587class YearEnd(YearOffset):

Callers 3

rollforwardMethod · 0.85
rollbackMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…