Returns a random datetime
354786
def datetime(anon, obj, field, val):
    
    return anon.faker.datetime(field=field)
1203908
def date_cast(date):
    '''
    
    '''
    if date is None:
        return datetime.datetime.now()
    elif isinstance(date, datetime.datetime):
        return date

    # fuzzy date
    try:
        if isinstance(date, six.string_types):
            try:
                if HAS_TIMELIB:
                    # py3: yes, timelib.strtodatetime wants bytes, not str :/
                    return timelib.strtodatetime(
                        salt.utils.stringutils.to_bytes(date))
            except ValueError:
                pass

            # not parsed yet, obviously a timestamp?
            if date.isdigit():
                date = int(date)
            else:
                date = float(date)

        return datetime.datetime.fromtimestamp(date)
    except Exception:
        if HAS_TIMELIB:
            raise ValueError('Unable to parse {0}'.format(date))

        raise RuntimeError(
                'Unable to parse {0}. Consider installing timelib'.format(date))
408888
def get_datetime(epoch):
    '''
    
    '''

    t = time.gmtime(epoch)
    dt = datetime.datetime(*t[:6])

    return dt
400674
def _random(cls):
        
        pid = os.getpid()
        if pid != cls._pid:
            cls._pid = pid
            cls.__random = _random_bytes()
        return cls.__random
336796
def random_get_instance() -> tcod.random.Random:
    
    return tcod.random.Random._new_from_cdata(
        ffi.cast("mersenne_data_t*", lib.TCOD_random_get_instance())
    )
763275
function generator(n) {
  if (!n) return Date.now().toString(36).toUpperCase();
  return Math.random().toString(36).substring(2, 10).toUpperCase();
}
544709
public static DateTime randomDay(int min, int max) {
		return DateUtil.offsetDay(DateUtil.date(), randomInt(min, max));
	}
1150611
def _get_date(data, position, dummy, opts):
    """"""
    end = position + 8
    millis = _UNPACK_LONG(data[position:end])[0]
    diff = ((millis % 1000) + 1000) % 1000
    seconds = (millis - diff) / 1000
    micros = diff * 1000
    if opts.tz_aware:
        return EPOCH_AWARE + datetime.timedelta(
            seconds=seconds, microseconds=micros), end
    else:
        return EPOCH_NAIVE + datetime.timedelta(
            seconds=seconds, microseconds=micros), end
312855
def datetime_from_timestamp(n, epoch=datetime.datetime.fromordinal(693594)):
    
    return epoch + datetime.timedelta(n)
807697
def get_timestamp(dt=None):
    '''
    
    '''

    if dt is None: dt = datetime.datetime.utcnow()
    t = dt.utctimetuple()

    return calendar.timegm(t)
1277705
def rnow(
        format='%Y-%m-%d %H:%M:%S',
        in_utc=False):
    

    if in_utc:
        return datetime.datetime.utcnow().strftime(
            format)
    else:
        return datetime.datetime.now().strftime(
            format)
1327408
def _rnd_datetime(self, start, end):
        
        return self.from_utctimestamp(
            random.randint(
                int(self.to_utctimestamp(start)),
                int(self.to_utctimestamp(end)),
            )
        )
20884
def randomdate(year: int) -> datetime.date:
    
    if calendar.isleap(year):
        doy = random.randrange(366)
    else:
        doy = random.randrange(365)

    return datetime.date(year, 1, 1) + datetime.timedelta(days=doy)
645088
def to_datetime(value):
    """"""
    if value is None:
        return None

    if isinstance(value, six.integer_types):
        return parser.parse(value)
    return parser.isoparse(value)
695885
def datetime(past=True, random=random):
    

    def year():
        if past:
            return random.choice(range(1950,2005))
        else:
            return _datetime.datetime.now().year + random.choice(range(1, 50))

    def month():
        return random.choice(range(1,12))

    def day():
        return random.choice(range(1,31))

    def hour():
        return random.choice(range(0,23))

    def minute():
        return random.choice(range(0,59))

    def second():
        return random.choice(range(0,59))

    try:
        return _datetime.datetime(year=year(),
                                  month=month(),
                                  day=day(),
                                  hour=hour(),
                                  minute=minute(),
                                  second=second())
    except ValueError:
        return datetime(past=past)
1173307
function datePredict() {
  var daysAhead = Math.floor(Math.random() * 5) + 2;

  var day = new Date();
  day.setDate(day.getDate() + daysAhead);
  var monthStr = (0, _dateformat2.default)(day, "mmmm");
  var dayStr = (0, _dateformat2.default)(day, "d");

  var rnum = Math.floor(Math.random() * 10);
  var str = void 0;
  if (rnum <= 4) {
    str = monthStr + ' ' + dayStr + ' will be an important day for you';
  } else if (rnum <= 7) {
    str = 'Interesting things await you on ' + monthStr + ' ' + dayStr;
  } else {
    str = 'The events of ' + monthStr + ' ' + dayStr + ' have the potential to change your life.';
  }
  return nu.sentenceCase(str);
}
250473
function randomDate() {
  var start = new Date(1995, 5, 16),
      end = new Date(),
      current = start,
      dates = [];

  while (current < end) {
    dates.push([
      current.getFullYear(),
      current.getMonth() + 1,
      current.getDate()
    ].join("-"));

    current.setDate(current.getDate() + 1);
  }

  return dates[Math.floor(Math.random() * dates.length)];
}