code: def gen_date_by_year(year):
          
          if isinstance(year, int) and len(str(year)) != 4:
              raise ValueError("year should be int year like 2018, but we got {}, {}".
                               format(year, type(year)))
          if isinstance(year, str) and len(year) != 4:
              raise ValueError("year should be string year like '2018', but we got {}, {}".
                               format(year, type(year)))
          if isinstance(year, int):
              year = str(year)
  
          date_str = GetRandomTime.gen_date_by_range(year + "-01-01", year + "-12-31", "%Y%m%d")
  
          return date_str
docs: 获取当前年的随机时间字符串
  
          :param:
              * year: (string) 长度为 4 位的年份字符串
  
          :return:
              * date_str: (string) 传入年份的随机合法的日期
          
          举例如下::
          
              print('--- GetRandomTime.gen_date_by_year demo ---')
              print(GetRandomTime.gen_date_by_year("2010"))
              print('---')
          
          执行结果::
          
              --- GetRandomTime.gen_date_by_year demo ---
              20100505
              ---