Example #1
0
def prevbusday(day_end_hour=18, day_end_min=0):
    """Returns the previous business day (Monday-Friday) at business frequency.

:Parameters:
    - day_end_hour : (int, *[18]* )
    - day_end_min : (int, *[0]*)

:Return values:
    If it is currently Saturday or Sunday, then the preceding Friday will be
    returned. If it is later than the specified day_end_hour and day_end_min,
    thisday('b') will be returned. Otherwise, thisday('b')-1 will be returned.
"""
    tempDate = dt.datetime.now()
    dateNum = tempDate.hour + float(tempDate.minute)/60
    checkNum = day_end_hour + float(day_end_min)/60
    if dateNum < checkNum:
        return thisday(_c.FR_BUS) - 1
    else:
        return thisday(_c.FR_BUS)
Example #2
0
        assert_equal(mdates[0].value, 24073)
        assert_equal(mdates[-1].value, 24084)
        # Using a date
        lag = mdates.find_dates(mdates[0])
        print mdates[lag]
        assert_equal(mdates[lag], mdates[0])
    if 0:
        hodie = today('D')
        D = DateArray(today('D'))
        assert_equal(D.freq, 6000)
    if 0:
        freqs = [x[0] for x in corelib.freq_dict.values() if x[0] != 'U']
        print freqs
        for f in freqs:
            print f
            today = thisday(f)
            assert(Date(freq=f, value=today.value) == today)
    if 0:
        D = date_array(freq='U', start_date=Date('U',1), length=10)
    if 0:
        dlist = ['2007-01-%02i' % i for i in (1,2,4,5,7,8,10,11,13)]
        ords = numpy.fromiter((DateTimeFromString(s).toordinal() for s in dlist),
                               float_)
    if 0:
        "Tests the automatic sorting of dates."
        D = date_array_fromlist(dlist=['2006-01','2005-01','2004-01'],freq='M')
        assert_equal(D.view(ndarray), [24037, 24049, 24061])

    if 1:
        dlist = ['2007-%02i' % i for i in range(1,5)+range(7,13)]
        mdates = date_array_fromlist(dlist, 'M')