Specific function to get start time and end time for MonthDateDaterange

        :param ref: time in seconds
        :type ref: int
        :return: tuple with start and end time
        :rtype: tuple (int, int)
439942
def get_start_and_end_time(self, ref=None):
        
        now = time.localtime(ref)
        if self.syear == 0:
            self.syear = now.tm_year
        day_start = find_day_by_offset(self.syear, self.smon, self.smday)
        start_time = get_start_of_day(self.syear, self.smon, day_start)

        if self.eyear == 0:
            self.eyear = now.tm_year
        day_end = find_day_by_offset(self.eyear, self.emon, self.emday)
        end_time = get_end_of_day(self.eyear, self.emon, day_end)

        now_epoch = time.mktime(now)
        if start_time > end_time:  # the period is between years
            if now_epoch > end_time:
                # check for next year
                day_end = find_day_by_offset(self.eyear + 1, self.emon, self.emday)
                end_time = get_end_of_day(self.eyear + 1, self.emon, day_end)
            else:
                # it s just that start was the last year
                day_start = find_day_by_offset(self.syear - 1, self.smon, self.emday)
                start_time = get_start_of_day(self.syear - 1, self.smon, day_start)
        else:
            if now_epoch > end_time:
                # just have to check for next year if necessary
                day_start = find_day_by_offset(self.syear + 1, self.smon, self.smday)
                start_time = get_start_of_day(self.syear + 1, self.smon, day_start)
                day_end = find_day_by_offset(self.eyear + 1, self.emon, self.emday)
                end_time = get_end_of_day(self.eyear + 1, self.emon, day_end)

        return (start_time, end_time)
927631
def end_date(self) -> Optional[datetime.date]:
        
        if not self.intervals:
            return None
        return self.end_datetime().date()
626005
def get_start_and_end_time(self, ref=None):
        
        now = time.localtime(ref)

        if self.syear == 0:
            self.syear = now.tm_year
        day_start = find_day_by_weekday_offset(self.syear, self.smon, self.swday, self.swday_offset)
        start_time = get_start_of_day(self.syear, self.smon, day_start)

        if self.eyear == 0:
            self.eyear = now.tm_year
        day_end = find_day_by_weekday_offset(self.eyear, self.emon, self.ewday, self.ewday_offset)
        end_time = get_end_of_day(self.eyear, self.emon, day_end)

        now_epoch = time.mktime(now)
        if start_time > end_time:  # the period is between years
            if now_epoch > end_time:  # check for next year
                day_end = find_day_by_weekday_offset(self.eyear + 1,
                                                     self.emon, self.ewday, self.ewday_offset)
                end_time = get_end_of_day(self.eyear + 1, self.emon, day_end)
            else:
                # it s just that the start was the last year
                day_start = find_day_by_weekday_offset(self.syear - 1,
                                                       self.smon, self.swday, self.swday_offset)
                start_time = get_start_of_day(self.syear - 1, self.smon, day_start)
        else:
            if now_epoch > end_time:
                # just have to check for next year if necessary
                day_start = find_day_by_weekday_offset(self.syear + 1,
                                                       self.smon, self.swday, self.swday_offset)
                start_time = get_start_of_day(self.syear + 1, self.smon, day_start)
                day_end = find_day_by_weekday_offset(self.eyear + 1,
                                                     self.emon, self.ewday, self.ewday_offset)
                end_time = get_end_of_day(self.eyear + 1, self.emon, day_end)

        return (start_time, end_time)
1361491
def get_end_date_metadata(self):
        
        metadata = dict(self._end_date_metadata)
        metadata.update({'existing_date_time_values': self.my_osid_object_form._my_map['endDate']})
        return Metadata(**metadata)
1184021
def get_start_time(self):
        
        start_time = c_double()
        self.library.get_start_time.argtypes = [POINTER(c_double)]
        self.library.get_start_time.restype = None
        self.library.get_start_time(byref(start_time))
        return start_time.value
1372283
public static long getTimeSpan(Date begin, Date end, int type) {
        long diff = end.getTime() - begin.getTime();
        switch (type) {
            case DAY:
            default:
                return diff / org.apache.commons.lang.time.DateUtils.MILLIS_PER_DAY;
            case HOUR:
                return diff / org.apache.commons.lang.time.DateUtils.MILLIS_PER_HOUR;
            case MINUTE:
                return diff / org.apache.commons.lang.time.DateUtils.MILLIS_PER_MINUTE;
            case SECOND:
                return diff / org.apache.commons.lang.time.DateUtils.MILLIS_PER_SECOND;
        }
    }
984215
public static long getMinutesDifference(Date startDate, Date endDate) {
		long startTime = startDate.getTime();
		long endTime = endDate.getTime();
		long diffTime = endTime - startTime;
		long diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(diffTime);
		return diffInMinutes;
	}
810805
def strftimegen(start_dt, end_dt):
    
    if start_dt > end_dt:
        raise ValueError("the start datetime is after the end datetime: (%r,%r)" % (start_dt, end_dt))

    def iterftime(string):
        date_subs = [i for i in DATE_FORMATS if i[1].search(string) is not None]
        if not date_subs:
            yield string
        else:
            dt = start_dt
            date_path = string
            while end_dt >= dt:
                for item in date_subs:
                    date_path = item[1].sub(dt.strftime(item[0]), date_path)
                yield date_path
                dt = dt + datetime.timedelta(days=1)

    return iterftime
625950
def timeticks(tdiff):
    
    if isinstance(tdiff, xarray.DataArray):  # len==1
        tdiff = timedelta(seconds=tdiff.values / np.timedelta64(1, 's'))

    assert isinstance(tdiff, timedelta), 'expecting datetime.timedelta'

    if tdiff > timedelta(hours=2):
        return None, None

    elif tdiff > timedelta(minutes=20):
        return MinuteLocator(byminute=range(0, 60, 5)), MinuteLocator(byminute=range(0, 60, 2))

    elif (timedelta(minutes=10) < tdiff) & (tdiff <= timedelta(minutes=20)):
        return MinuteLocator(byminute=range(0, 60, 2)), MinuteLocator(byminute=range(0, 60, 1))

    elif (timedelta(minutes=5) < tdiff) & (tdiff <= timedelta(minutes=10)):
        return MinuteLocator(byminute=range(0, 60, 1)), SecondLocator(bysecond=range(0, 60, 30))

    elif (timedelta(minutes=1) < tdiff) & (tdiff <= timedelta(minutes=5)):
        return SecondLocator(bysecond=range(0, 60, 30)), SecondLocator(bysecond=range(0, 60, 10))

    elif (timedelta(seconds=30) < tdiff) & (tdiff <= timedelta(minutes=1)):
        return SecondLocator(bysecond=range(0, 60, 10)), SecondLocator(bysecond=range(0, 60, 2))

    else:
        return SecondLocator(bysecond=range(0, 60, 2)),  SecondLocator(bysecond=range(0, 60, 1))
68564
def duration(self):
        
        if not self.started:
            return None
        start = self.started
        end = self.completed
        if not end:
            end = datetime.utcnow()
        return end - start
1074185
def get_month_start_end_day():
    
    t = date.today()
    n = mdays[t.month]
    return (date(t.year, t.month, 1), date(t.year, t.month, n))
814384
def getByTime(self, startTime=None, endTime=None):
        
        collections = self.get_data_collections()

        if startTime is not None:
            startTime = float(startTime)
        if endTime is not None:
            endTime = float(endTime)

        if startTime is not None and endTime is not None:
            timeQuery = {"$and": [{"timestamps": {"$gt": startTime}},
                                  {"timestamps": {"$lt": endTime}}]}
        elif startTime is not None and endTime is None:
            timeQuery = {"timestamps": {"$gt": startTime}}
        elif startTime is None and endTime is not None:
            timeQuery = {"timestamps": {"$lt": endTime}}

        IDs = []

        for coll in collections:
            docs = self.noteDB[coll].find(timeQuery, {"ID": 1, "_id": 0})
            for doc in docs:
                IDs.append(doc['ID'])

        return IDs
902906
def get_month_start_date(self):
        """"""
        now = timezone.now()
        return timezone.datetime(day=1, month=now.month, year=now.year, tzinfo=now.tzinfo)
166500
function getElapsedTime(startTime) {
	const prettyHrtime = require("pretty-hrtime");
	const timeDiff = process.hrtime(startTime);
	return prettyHrtime(timeDiff);
}
860644
def daterange_end(value):
    ''''''
    if not value:
        return None
    elif isinstance(value, datetime):
        return value.date()
    elif isinstance(value, date):
        return value

    result = parse_dt(value).date()
    dashes = value.count('-')

    if dashes >= 2:
        # Full date
        return result
    elif dashes == 1:
        # Year/Month
        return result + relativedelta(months=+1, days=-1, day=1)
    else:
        # Year only
        return result.replace(month=12, day=31)
1087366
def prettyDateDifference(startTime, finishTime=None):
    
    from datetime import datetime

    if startTime is None:
        return None

    if not isinstance(startTime, (int, datetime)):
        raise RuntimeError("Cannot parse time")

    endTime = finishTime or datetime.now()

    if isinstance(startTime, int):
        diff = endTime - datetime.fromtimestamp(startTime)
    elif isinstance(startTime, datetime):
        diff = endTime - startTime
    else:
        diff = endTime - endTime

    second_diff = diff.seconds
    day_diff = diff.days

    if day_diff < 0:
        return ''

    if day_diff == 0:
        if second_diff < 10:
            return "just now"
        if second_diff < 60:
            return str(second_diff) + " seconds ago"
        if second_diff < 120:
            return "a minute ago"
        if second_diff < 3600:
            return str(int(second_diff / 60)) + " minutes ago"
        if second_diff < 7200:
            return "an hour ago"
        if second_diff < 86400:
            return str(int(second_diff / 3600)) + " hours ago"
    if day_diff == 1:
        return "Yesterday"
    if day_diff < 7:
        return str(day_diff) + " days ago"
548076
def start_of_day(self) -> datetime:
        
        self.value = datetime(self.value.year, self.value.month, self.value.day)
        return self.value