class_docstr: Describes how the time dimension for metrics should be constrained.
class_docstr_tok: ["Describes","how","the","time","dimension","for","metrics","should","be","constrained","."]
docstr: Moves the start of the time constraint back by <time_unit_count> windows.
  
  if the metric is weekly-active-users (ie window = 1 week) it moves time_constraint.start one week earlier
docstr_tok: ["Moves","the","start","of","the","time","constraint","back","by","<","time_unit_count",">","windows",".","if","the","metric","is","weekly-active-users","(","ie","window","=","1","week",")","it","moves","time_constraint.start","one","week","earlier"]
code: def _adjust_time_constraint_start_by_window(
      self,
      time_granularity: TimeGranularity,
      time_unit_count: int,
  ) -> TimeRangeConstraint:
      """Moves the start of the time constraint back by <time_unit_count> windows.
  
      if the metric is weekly-active-users (ie window = 1 week) it moves time_constraint.start one week earlier
      """
      start_ts = pd.Timestamp(self.start_time)
      offset = offset_period(time_granularity) * time_unit_count
      adjusted_start = (start_ts - offset).to_pydatetime()
      return TimeRangeConstraint(
          start_time=adjusted_start,
          end_time=self.end_time,
      )
  
imports: from __future__ import annotations
  import datetime
  import logging
  from dataclasses import dataclass
  from typing import Optional
  import pandas
  from dbt_semantic_interfaces.dataclass_serialization import SerializableDataclass
  from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity
  from metricflow.time.time_granularity import offset_period
label_desc: Use image node_id 6 for calling the TimeRangeConstraint obj's underlying member method code with example usage: obj._adjust_time_constraint_start_by_window(time_granularity, time_unit_count) and returns: TimeRangeConstraint