evolve to the new process state at the next date

        :param date new_date: date or point in time of the new state
        :return State:
975852
def evolve(self, new_date):
        
        if all(p.state.date == new_date for p in self.producers):
            return [p.state for p in self.producers]

        if self._cholesky is not None:
            q = [self.random.gauss(0., 1.) for _ in range(len(self._cholesky))]
            q = list(self._cholesky.dot(q))
        else:
            q = list()

        state = list()
        for p in self.producers:
            if len(self._driver_index[p]) == len(p.diffusion_driver):
                qq = [q[i] for i in self._driver_index[p]]
            elif len(self._driver_index[p]) < len(p.diffusion_driver):
                qq = list()
                for d in p.diffusion_driver:
                    qqq = q[self._diffusion_driver.index(d)] if d in self._diffusion_driver else self.random.gauss(0., 1.)
                    qq.append(qqq)
            else:
                qq = [self.random.gauss(0., 1.) for _ in p.diffusion_driver]

            p.random.extend(qq)
            state.append(p.evolve(new_date))

        return state
360045
def next_run_in(self, utc_now=None):
        
        if utc_now is None:
            utc_now = datetime.utcnow()

        if self.is_alive():
            smallest_timedelta = timedelta(days=99, hours=0, minutes=0, seconds=0, microseconds=0, milliseconds=0)
            for event_time in self.timestamps:
                next_trigger = event_time.next_trigger_frequency(utc_now)
                if next_trigger - utc_now < smallest_timedelta:
                    smallest_timedelta = next_trigger - utc_now
            return smallest_timedelta

        else:
            return None
908140
@Override
    public Date nextExecutionTime(TriggerContext triggerContext) {
        if (triggerContext.lastScheduledExecutionTime() == null) {
            return new Date(System.currentTimeMillis() + this.initialDelay);
        } else if (this.fixedRate) {
            return new Date(triggerContext.lastScheduledExecutionTime().getTime() + this.period);
        }
        return new Date(triggerContext.lastCompletionTime().getTime() + this.period);
    }
265954
def _try_convert_to_date(self, data):
        

        # no conversion on empty
        if not len(data):
            return data, False

        new_data = data
        if new_data.dtype == 'object':
            try:
                new_data = data.astype('int64')
            except:
                pass

        # ignore numbers that are out of range
        if issubclass(new_data.dtype.type, np.number):
            in_range = (isnull(new_data.values) | (new_data > self.min_stamp) |
                        (new_data.values == iNaT))
            if not in_range.all():
                return data, False

        date_units = (self.date_unit,) if self.date_unit else self._STAMP_UNITS
        for date_unit in date_units:
            try:
                new_data = to_datetime(new_data, errors='raise',
                                       unit=date_unit)
            except ValueError:
                continue
            except:
                break
            return new_data, True
        return data, False
756006
def next_tick(date, interval=15):
    '''
    
    '''
    # Intuition works with utc dates, conversion are made for I/O
    now = dt.datetime.now(pytz.utc)
    live = False
    # Sleep until we reach the given date
    while now < date:
        time.sleep(interval)
        # Update current time
        now = dt.datetime.now(pytz.utc)
        # Since we're here, we waited a future date, so this is live trading
        live = True
    return live
546021
def as_dates(self):
        
        new_start = self.start.date() if self.start and isinstance(self.start, datetime.datetime) else self.start
        new_end = self.end.date() if self.end and isinstance(self.end, datetime.datetime) else self.end
        return DateRange(new_start, new_end, CLOSED_CLOSED)
354195
def setCurrentDate( self, date ):
        
        if ( date == self._currentDate or not date.isValid() ):
            return
        
        self._currentDate = date
        self.markForRebuild()
        
        parent = self.parent()
        if ( not parent.signalsBlocked() ):
            parent.currentDateChanged.emit(date)
            parent.titleChanged.emit(self.title())
1067644
def date_added(self, date_added):
        
        date_added = self._utils.format_datetime(date_added, date_format='%Y-%m-%dT%H:%M:%SZ')

        self._data['dateAdded'] = date_added
        request = self._base_request
        request['dateAdded'] = date_added
        return self._tc_requests.update(request, owner=self.owner)
554272
def new(cls):

        ''' 
        '''

        dT = datetime.utcnow().replace(tzinfo=pytz.utc)
        dt_kwargs = {
            'year': dT.year,
            'month': dT.month,
            'day': dT.day,
            'hour': dT.hour,
            'minute': dT.minute,
            'second': dT.second,
            'microsecond': dT.microsecond,
            'tzinfo': dT.tzinfo
        }
        return labDT(**dt_kwargs)
345188
public static Timestamp of(Date date) {
        if (date == null)
            return null;
        long time = date.getTime();
        int nanoSec = (int) (time % 1000) * 1000000;
        long epochSec = (time / 1000);
        return createWithCarry(epochSec, nanoSec);
    }
438724
def _update_state(self, state_type: str, value: str) -> datetime:
        
        timestamp = datetime.utcnow()
        field = '{}_state'.format(state_type)
        old_state = DB.get_hash_value(self._key, field)
        DB.set_hash_value(self._key, field, value, pipeline=True)
        DB.set_hash_value(self._key, '{}_timestamp'.format(state_type),
                          timestamp.isoformat(), pipeline=True)
        DB.execute()

        # Publish an event to notify subscribers of the change in state
        self.publish('{}_state_updated'.format(state_type),
                     event_data=dict(state=value, old_state=old_state))

        return timestamp
267333
def _process_new_state(cls, new_state, unprocessed, processed):
        """"""
        if isinstance(new_state, str):
            # an existing state
            if new_state == '#pop':
                return -1
            elif new_state in unprocessed:
                return (new_state,)
            elif new_state == '#push':
                return new_state
            elif new_state[:5] == '#pop:':
                return -int(new_state[5:])
            else:
                assert False, 'unknown new state %r' % new_state
        elif isinstance(new_state, combined):
            # combine a new state from existing ones
            tmp_state = '_tmp_%d' % cls._tmpname
            cls._tmpname += 1
            itokens = []
            for istate in new_state:
                assert istate != new_state, 'circular state ref %r' % istate
                itokens.extend(cls._process_state(unprocessed,
                                                  processed, istate))
            processed[tmp_state] = itokens
            return (tmp_state,)
        elif isinstance(new_state, tuple):
            # push more than one state
            for istate in new_state:
                assert (istate in unprocessed or
                        istate in ('#pop', '#push')), \
                    'unknown new state ' + istate
            return new_state
        else:
            assert False, 'unknown new state def %r' % new_state
535713
def from_ad_date(cls, date):
        
        functions.check_valid_ad_range(date)
        days = values.START_EN_DATE - date

        # Add the required number of days to the start nepali date
        start_date = NepDate(values.START_NP_YEAR, 1, 1)
        # No need to update as addition already calls update
        return start_date + (date - values.START_EN_DATE)
403298
def set_state(self, new_state):
        
        # Make sure it's a valid state
        if new_state not in self.STATES:
            raise ValueError('Invalid state value: %r' % new_state)

        # Set the state
        LOGGER.debug('State changing from %s to %s', self.STATES[self.state],
                     self.STATES[new_state])
        self.state = new_state
        self.state_start = time.time()
705542
public static Date newDate(final Date original) {
        return original != null ? new Date(original.getTime()) : null;
    }
152000
def update(self, date, data=None, inow=None):
        
        # resolve stale state
        self.root.stale = False

        # update helpers on date change
        # also set newpt flag
        newpt = False
        if self.now == 0:
            newpt = True
        elif date != self.now:
            self._net_flows = 0
            self._last_price = self._price
            self._last_value = self._value
            self._last_fee = 0.0
            newpt = True

        # update now
        self.now = date
        if inow is None:
            if self.now == 0:
                inow = 0
            else:
                inow = self.data.index.get_loc(date)

        # update children if any and calculate value
        val = self._capital  # default if no children

        if self.children is not None:
            for c in self._childrenv:
                # avoid useless update call
                if c._issec and not c._needupdate:
                    continue
                c.update(date, data, inow)
                val += c.value

        if self.root == self:
            if (val < 0) and not self.bankrupt:
                # Declare a bankruptcy
                self.bankrupt = True
                self.flatten()

        # update data if this value is different or
        # if now has changed - avoid all this if not since it
        # won't change
        if newpt or self._value != val:
            self._value = val
            self._values.values[inow] = val

            bottom = self._last_value + self._net_flows
            if bottom != 0:
                ret = self._value / (self._last_value + self._net_flows) - 1
            else:
                if self._value == 0:
                    ret = 0
                else:
                    raise ZeroDivisionError(
                        'Could not update %s. Last value '
                        'was %s and net flows were %s. Current'
                        'value is %s. Therefore, '
                        'we are dividing by zero to obtain the return '
                        'for the period.' % (self.name,
                                             self._last_value,
                                             self._net_flows,
                                             self._value))

            self._price = self._last_price * (1 + ret)
            self._prices.values[inow] = self._price

        # update children weights
        if self.children is not None:
            for c in self._childrenv:
                # avoid useless update call
                if c._issec and not c._needupdate:
                    continue

                if val != 0:
                    c._weight = c.value / val
                else:
                    c._weight = 0.0

        # if we have strategy children, we will need to update them in universe
        if self._has_strat_children:
            for c in self._strat_children:
                # TODO: optimize ".loc" here as well
                self._universe.loc[date, c] = self.children[c].price

        # Cash should track the unallocated capital at the end of the day, so
        # we should update it every time we call "update".
        # Same for fees
        self._cash.values[inow] = self._capital
        self._fees.values[inow] = self._last_fee

        # update paper trade if necessary
        if newpt and self._paper_trade:
            self._paper.update(date)
            self._paper.run()
            self._paper.update(date)
            # update price
            self._price = self._paper.price
            self._prices.values[inow] = self._price
1284837
function () {
            // get client's current date
            var date = new Date();

            // turn date to utc
            var utc = date.getTime() + (date.getTimezoneOffset() * 60000);

            // set new Date object
            var new_date = new Date(utc + (3600000*settings.offset))

            return new_date;
        }