예제 #1
0
	def shift_forward(self, numPeriods):
		if self.periodicity == SECONDS:
			self.startDT = dt_add_seconds(self.startDT, numPeriods)
			self.endDT = dt_add_seconds(self.endDT, numPeriods)
		elif self.periodicity == MONTHS:
			self.startDT = dt_add_months(self.startDT, numPeriods)
			self.endDT = dt_add_months(self.endDT, numPeriods)
		elif self.periodicity == QUARTERS:
			self.startDT = dt_add_months(self.startDT, 3*numPeriods)
			self.endDT = dt_add_months(self.endDT, 3*numPeriods)
		elif self.periodicity == YEARS:
			self.startDT = dt_add_months(self.startDT, 12*numPeriods)
			self.endDT = dt_add_months(self.endDT, 12*numPeriods)
		else:
			raise NotImplementedError
예제 #2
0
	def get_date_generator(self, outputType=EPOCH_TYPE):
		# Set Output Function
		if outputType==DATETIME_TYPE:
			outputFn = lambda d: d
		elif outputType==EPOCH_TYPE:
			outputFn = dt_datetime_to_epoch
		elif outputType==DATESTRING_TYPE:
			outputFn = lambda d: strftime(d, '%Y-%m-%d')
		else:
			raise NameError
		# Yield Dates
		currentDT = self.startDT
		while currentDT < self.endDT:
			yield outputFn(currentDT)
			if self.periodicity == SECONDS:
				currentDT = dt_add_seconds(currentDT, 1)
			elif self.periodicity == MONTHS:
				currentDT = dt_add_months(currentDT, 1)
			elif self.periodicity == QUARTERS:
				currentDT = dt_add_months(currentDT, 3)
			elif self.periodicity == YEARS:
				currentDT = dt_add_months(currentDT, 12)
			else:
				raise NotImplementedError
		# Yield End
		yield outputFn(self.endDT)
예제 #3
0
	def truncate_start(self, numPeriods):
		if self.periodicity == SECONDS:
			self.startDT = dt_add_seconds(self.startDT, numPeriods)
		elif self.periodicity == MONTHS:
			self.startDT = dt_add_months(self.startDT, numPeriods)
		elif self.periodicity == QUARTERS:
			self.startDT = dt_add_months(self.startDT, 3*numPeriods)
		elif self.periodicity == YEARS:
			self.startDT = dt_add_months(self.startDT, 12*numPeriods)
		else:
			raise NotImplementedError