#!/usr/bin/python3

# ## {R2D2919B742E} ##
# ###########################################################################
# What if magic existed?
# What if a place existed where your every thought and dream come to life.
# There is only one catch: it has to be written down.
# Such a place exists, it is called programming.
#    - Scott Taylor Reph, RightThumb.com
# ###########################################################################
# ## {C3P0D40fAe8B} ##
##################################################
import os, sys, time
##################################################
import _rightThumb._construct as __
appDBA = __.clearFocus( __name__, __file__ )
__.appReg = appDBA
def focus( parentApp='', childApp='', reg=True ):
    global appDBA
    f = __.appName( appDBA, parentApp, childApp )
    if reg:
        __.appReg = f
    return f
__.registeredApps.append( focus() )
import _rightThumb._base3 as _
_.load()
##################################################
import _rightThumb._vars as _v
import _rightThumb._string as _str
##################################################

def appSwitches():
    _.switches.register( 'Files', '-f,-file,-files','file.txt', description='Files', isRequired=True )
    _.switches.register( 'Clients', '-clients' )
    _.switches.register( 'Calendar', '-cal' )
    _.switches.register( 'Errors', '-error' )
    _.switches.register( 'Epoch', '-epoch' )
    _.switches.register( 'SaveDate', '-date-file' )
    _.switches.register( 'SaveText', '-text-file' )
    pass

_.autoBackupData = __.setting('receipt-log')
__.releaseAcquiredData = __.setting('receipt-file')
__.myFileLocations_SKIP_VALIDATION = False
__.isRequired_Pipe = False
__.isRequired_Pipe_or_File = False
__.pre_error = False
__.switch_raw = []
# __.switch_raw = [ 'Delim' ]
# __.isRequired_or_List = ['Pipe','Files','Plus']
# __.setting( 'app-switches-raw', [ 'Delim' ] )


_.appInfo[focus()] = {
    'file': 'vps-hoth-7i0ZA-7GzGHN-invoices-calendar.py',
    'liveAppName': __.thisApp( __file__ ),
    'description': 'create schedule',
    'categories': [
                        'calendar',
                ],
    'usage': [
                        # 'epy another',
                        # 'e nmap',
                        # '',
    ],
    'relatedapps': [
                        # 'p another -file file.txt',
                        # '',
    ],
    'prerequisite': [
                        # 'p another -file file.txt',
                        # '',
    ],
    'examples': [
                        _.hp('p vps-hoth-7i0ZA-7GzGHN-invoices-calendar -f invoices.json -cal cal-dirty.json -clients clients-E304AC38-A5E6.json'),
                        '',
    ],
    'columns': [
                       # { 'name': 'name', 'abbreviation': 'n' },
                       # { 'name': '{1}', 'abbreviation': '{0}', 'sort': '{2}' },
    ],
    'aliases': [
                       # 'this',
                       # 'app',
    ],
    'notes': [
                       # {},
    ],
}

_.appData[focus()] = {
        'start': __.startTime,
        'uuid': '',
        'audit': [],
        'pipe': False,
        'data': {
                    'field': {'sent': [], 'received': [] }, # { 'label': '', 'context': [],  }
                    'table': {'sent': [], 'received': [] }, 
        },
    }



def registerSwitches( argvProcessForce=False ):
    global appDBA
    if not __.appReg == appDBA and appDBA in __.appReg:

        if not __name__ == '__main__':
            _.argvProcess = argvProcessForce
        else:
            _.argvProcess = True

        _.load()
        _.appInfo[__.appReg] = _.appInfo[appDBA]
        _.appData[__.appReg] = _.appData[appDBA]
    __.constructRegistration( _.appInfo[__.appReg]['file'],__.appReg )
    appSwitches()

    _.myFileLocation_Print = False
    _.switches.trigger( 'Files', _.myFileLocations, vs=True )
    _.switches.trigger( 'Folder', _.myFolderLocations )
    _.switches.trigger( 'URL', _.urlTrigger )
    _.switches.trigger( 'Ago', _.timeAgo )
    _.switches.trigger( 'Duration', _.timeFuture )
    
    _.defaultScriptTriggers()
    _.switches.process()


if not __name__ == '__main__':
    _.argvProcess = False
else:
    _.argvProcess = True

registerSwitches()


def fieldSet( switchName, switchField, switchValue, theFocus=False ):
    if not type( theFocus ) == bool:
        theFocus = theFocus
    _.switches.fieldSet( switchName, switchField, switchValue, theFocus )


if __name__ == '__main__':
    if not sys.stdin.isatty():
        _.setPipeData( sys.stdin.readlines(), __.appReg, clean=True )


_.postLoad( __file__ )

########################################################################################
#START



def cleanup(data):
    data = data.replace( '\r', '' )
    data = data.replace( '\t', ' ' )
    data = _str.replaceDuplicate( data, ' ' )
    data = _str.replaceDuplicate( data, '\n' )
    data = _str.cleanBE( data, ' ' )
    data = _str.cleanBE( data, '\n' )
    data = data.replace( ' \n', '\n' )
    data = data.replace( ', ', ',' )
    data = data.lower()
    return data

svc_dic = {}

svc_list = '''
run generator, manual mode
oil change
change out, synthetic oil
check air filter
change spark plugs
check generator board
check fuses on board
check generator tap for voltage
check generator tap for hertz
check grounding bonds
check oil
check, transfer switch
check, transfer switch, fuses
check boards, transfer switch
breaker, transfer switch, start test
transfer switch, switch test
turn, breaker, transferred
wait, generator, cool down cycle
auto to complete
check battery
oil filters, recycle
start up of generator
programming of generator
transfer switch to watch utilities
new rubber intake tube
check, controls
antifreeze
air intake, foam ring
programming
'''
svc_list = cleanup(svc_list)
svc_list = cleanup(svc_list)

def service_items(svc,rec):
    global svc_list
    global svc_dic
    svcs = []
    for ii,sv in enumerate(svc):
        sv = _str.replaceDuplicate( sv, ' ' )
        sv = _str.cleanBE( sv, ' ' )
        if len(sv):
            found = False

            for item in svc_list.split('\n'):
                if  _.showLine(sv, plus=item.split(',')):
                    svcs.append(item)
                    svc_dic[item] = sv
                    found = True
                    # _.cp(item,'green')
                else:
                    pass

            if not found and _.switches.isActive('Errors'):
                _.cp( [sv] ,'red')
    return svcs


def services(script,rec):
    script = script.lower()
    lines = script.split('\n')
    if not 'major service:' in lines and not 'minor service' in script:
        _.cp( script, 'red' )
        return None
    if not 'major service:' in lines:
        for line in lines:
            if 'minor service' in line:
                line = line.split('minor service')[1]
                return service_items(line.split(','),rec)
                # _.pr(line)
        return None
    i = lines.index('major service:')
    txt = lines[i+1]
    txt = txt.replace('.',',')
    svc = txt.split(',')

    return service_items(svc,rec)


        
    # sys.exit()
    return svc

def process(script,rec):
    y = 1
    if 'second year' in script.lower():
        y = 2
    else:
        y = 1
    return y, services(script,rec)

soon = _.timeAgo( '+10y', time.time() )
cnt=0


def cal( y,svc, rec, iid=None ):
    global soon
    global cnt
    global clients
    global ics_fileA
    global ics_fileB
    global json_fileA
    global json_fileB
    global CreatedDateA
    global CreatedDateB


    dicky = {
                ''
    }
    epoch = rec['epoch']
    if y == 1:
        # renew = _.timeAgo( '+6m', epoch )
        renew = _.timeAgo_do( '+6m', epoch )
        exp = _.timeAgo_do( '+11m', epoch )
    elif y == 2:
        renew = _.timeAgo_do( '+1y6m', epoch )
        exp = _.timeAgo_do( '+1y11m', epoch )
    if exp < time.time(): return None;

    audit = {
                'epoch': _.friendlyDate(epoch),
                'renew': _.friendlyDate(renew),
                'exp': _.friendlyDate(exp),
    }
    if audit['renew'].startswith('19'): renew=0;
    if audit['exp'].startswith('19'): exp=0;
    if '2021' in audit['renew']: renew=0;
    if '2021' in audit['exp']: exp=0;
    if 'year' in _.v.do:
        _.pr( 774, audit['exp'].split('-')[0] )
    # if '2029' in str(audit):
    #     _.pv(rec)
    #     _.pv(audit)
    #     sys.exit()
    # _.pr()
    # _.pr( rec['DocumentDate'] )
    if exp < time.time():
        return None

    if exp > time.time() and exp < soon:
        cnt+=1

    # if renew < time.time():
    #   if exp > time.time():
    #       _.cp( _.friendlyDate(exp).split(' ')[0], 'red' )
    #   else:
    #       _.cp( _.friendlyDate(renew).split(' ')[0], 'yellow' )
    # else:
    #   _.cp( _.friendlyDate(renew).split(' ')[0], 'green' )
    pass

    if renew > time.time() or exp > time.time():
        # _.pr(rec['created'])
        ida = _.uuidE(iid,epoch=rec['created'])
        # _.pr(_.over( ida, '7r' ))
        # sys.exit()
        renew=dc(renew)
        exp=dc(exp)

        rid= _.genUUID(note='',c=1)
        CLID = rec['Client-Id']
        CreatedDate = rec['CreatedDate']
        # if type(CLID) == str and CLID in clients:
        cemail = ''
        cphone = ''
        if CLID in clients:
            CLIENT = clients[CLID]
            CN = _clean.imp.clean7(CLIENT['BillingName'])
            f = _clean.imp.app.record.profile(CLIENT)['fields']

            if 'phone' in f:
                cphone = ','.join(f['phone'])
            if 'email' in f:
                cemail = ','.join(f['email'])
        else:
            CLIENT = {}
            CN = 'THECLIENT'

        
        f = _clean.imp.app.record.profile(rec)['fields']
        email = ''
        phone = ''
        if 'phone' in f:
            phone = ','.join(f['phone'])
        if 'email' in f:
            email = ','.join(f['email'])
        pass
        remType='email'
        remType=None
        fi=None

        

        if CN == 'THECLIENT':
            CreatedDateB.append(rec['CreatedDate'])
            fi={
                    'client': CN,
                    'cl-id': rec['Client-Id'],
                    'inv-id': iid,
                    'title-renew': 'Agreement renewal notice '+CN,
                    'title-expire': 'Agreement expiration notice '+CN,
                    # 'date': _.isDate(cal_time_fix2(renew),f=_.v.f),
                    'date-renew': _.isDate(cal_time_fix2(renew),f=_.v.f),
                    'date-expire': _.isDate(cal_time_fix2(exp),f=_.v.f),
                    'created': rec['created'],
                    'renew': renew,
                    'exp': exp,
                    # 'expire': exp+2674760,
                    'fields': f,
                    'cal-id': _.over( ida, '7r' ),
                    'cemail': cemail,
                    'email': email,
                    'phone': _str.do('be', ','.join([phone,cphone]),','),
                    'invoice': rec,
                    'textme': False,
                    'files': {},
            }
            try:
                while 'sat' in fi['date-renew']['dow'].lower() or 'sun' in fi['date-renew']['dow'].lower():
                    fi['date-renew']=_.isDate(  fi['date-renew']['epoch']+86400  ,f=_.v.f)
                    # fi['date']=fi['date-renew']
            except Exception as e:
                pass
            try:
                while 'sat' in fi['date-expire']['dow'].lower() or 'sun' in fi['date-expire']['dow'].lower():
                    fi['date-expire']=_.isDate(  fi['date-expire']['epoch']+86400  ,f=_.v.f)
            except Exception as e:
                pass


            try:
                fi['date-renew']['id'] = _.over( ida, '0r' )
            except Exception as e:
                pass
            try:
                fi['date-expire']['id'] = _.over( ida, '0e' )
            except Exception as e:
                pass

            json_fileB.append(fi)
            if renew > time.time():

                try:
                    r=__iCalTemplate(fi['title-renew'], fi['date-renew']['iso'], _.over( ida, '0r' ), email, remType=remType,desc=_.over( ida, '7r' ))
                    r0=__iCalTemplate(fi['title-renew'], fi['date-renew']['iso'], _.over( ida, '0r' ), email, remType=None,desc=_.over( ida, '0r' ))
                    fi['files']['renew-0'] = r0
                    ics_fileB.append(r)
                except Exception as e:
                    # _.pr(_.over( ida, 'XX' ),fi['date-renew'])
                    # _.pr(1000164753876,e)
                    pass
                try:
                    r1=__iCalTemplate(fi['title-renew'], fi['date-renew']['iso'], _.over( ida, '0r' ), email, remType='email',desc=_.over( ida, '1r' ))
                    fi['files']['renew-1'] = r1
                except Exception as e:
                    # _.pr(_.over( ida, 'XX' ),fi['date-renew'])
                    # _.pr(1001647538767,e)
                    pass
                
            if exp > time.time():
                # _.pr(_.over( ida, 'XX' ))
                try:
                    r=__iCalTemplate(fi['title-expire'], fi['date-expire']['iso'], _.over( ida, '0e' ), email, remType=remType,desc=_.over( ida, '7e' ))
                    r0=__iCalTemplate(fi['title-expire'], fi['date-expire']['iso'], _.over( ida, '0e' ), email, remType=None,desc=_.over( ida, '0e' ))
                    fi['files']['exp-0'] = r0
                    ics_fileB.append(r)
                except Exception as e:
                    # _.pr(_.over( ida, 'XX' ),fi['date-renew'])
                    # _.pr(1011647538767,e)
                    pass
                try:
                    r1=__iCalTemplate(fi['title-expire'], fi['date-expire']['iso'], _.over( ida, '0e' ), email, remType='email',desc=_.over( ida, '1e' ))
                    fi['files']['exp-1'] = r1
                except Exception as e:
                    # _.pr(_.over( ida, 'XX' ),fi['date-renew'])
                    # _.pr(1021647538767,e)
                    pass
                
        else:
            CreatedDateA.append(rec['CreatedDate'])
            fi={
                    'client': CN,
                    'cl-id': rec['Client-Id'],
                    'inv-id': iid,
                    'title-renew': 'Agreement renewal notice '+CN,
                    'title-expire': 'Agreement expiration notice '+CN,
                    # 'date': _.isDate(cal_time_fix2(renew),f=_.v.f),
                    'date-renew': _.isDate(cal_time_fix2(renew),f=_.v.f),
                    'date-expire': _.isDate(cal_time_fix2(exp),f=_.v.f),
                    'created': rec['created'],
                    'renew': renew,
                    'exp': exp,
                    # 'expire': exp+2674760,
                    'fields': f,
                    'cal-id': _.over( ida, '7r' ),
                    'cemail': cemail,
                    'email': email,
                    'phone': _str.do('be', ','.join([phone,cphone]),','),
                    'textme': False,
                    'files': {},
            }
            try:
                while 'sat' in fi['date-renew']['dow'].lower() or 'sun' in fi['date-renew']['dow'].lower():
                    fi['date-renew']=_.isDate(  fi['date-renew']['epoch']+86400  ,f=_.v.f)
                    # fi['date']=fi['date-renew']
            except Exception as e:
                pass
            try:
                while 'sat' in fi['date-expire']['dow'].lower() or 'sun' in fi['date-expire']['dow'].lower():
                    fi['date-expire']=_.isDate(  fi['date-expire']['epoch']+86400  ,f=_.v.f)
            except Exception as e:
                pass

            try:
                fi['date-renew']['id'] = _.over( ida, '0r' )
            except Exception as e:
                pass
            try:
                fi['date-expire']['id'] = _.over( ida, '0e' )
            except Exception as e:
                pass

            json_fileA.append(fi)
            if renew > time.time():
                # _.pr(_.over( ida, 'XX' ))
                try:
                    r=__iCalTemplate(fi['title-renew'], fi['date-renew']['iso'], _.over( ida, '0r' ), email, remType=remType,desc=_.over( ida, '7r' ))
                    r0=__iCalTemplate(fi['title-renew'], fi['date-renew']['iso'], _.over( ida, '0r' ), email, remType=None,desc=_.over( ida, '0r' ))
                    fi['files']['renew-0'] = r0
                    ics_fileA.append(r)
                except Exception as e:
                    # _.pr(1031647538767,e)
                    # _.pr(_.over( ida, 'XX' ),fi['date-renew'])
                    pass
                try:
                    r1=__iCalTemplate(fi['title-renew'], fi['date-renew']['iso'], _.over( ida, '0r' ), email, remType='email',desc=_.over( ida, '1r' ))
                    fi['files']['renew-1'] = r1
                except Exception as e:
                    # _.pr(1041647538767,e)
                    # _.pr(_.over( ida, 'XX' ),fi['date-renew'])
                    pass
                # _.pr()
                
                if 'ics' in _.v.do:
                    _.pr(r)
                
            if exp > time.time():
                # _.pr(_.over( ida, 'XX' ))
                try:
                    r=__iCalTemplate(fi['title-expire'], fi['date-expire']['iso'], _.over( ida, '0e' ), email, remType=remType,desc=_.over( ida, '7e' ))
                    r0=__iCalTemplate(fi['title-expire'], fi['date-expire']['iso'], _.over( ida, '0e' ), email, remType=None,desc=_.over( ida, '0e' ))
                    fi['files']['exp-0'] = r0
                    ics_fileA.append(r)
                except Exception as e:
                    # _.pr(1051647538767,e)
                    # _.pr(_.over( ida, 'XX' ),fi['date-renew'])
                    pass
                try:
                    r1=__iCalTemplate(fi['title-expire'], fi['date-expire']['iso'], _.over( ida, '0e' ), email, remType='email',desc=_.over( ida, '1e' ))
                    fi['files']['exp-1'] = r1
                except Exception as e:
                    # _.pr(1061647538767,e)
                    # _.pr(_.over( ida, 'XX' ),fi['date-renew'])
                    pass
                # _.pr()
                if 'ics' in _.v.do:
                    _.pr(r)
        if not fi is None:
            _.v.records.append(fi)



def action():
    # for x in dir(vDatetime):
    #     _.pr(x)
    # x=vDatetime.to_ical( _.isDate(time.time(),f='fdate') )
    # _.pr(x)
    # sys.exit()
    # should be   Single-Task   OR   Imply-Architecture-Functions   OR   CLASSES!!
    load()
    global invoices
    global svc_dic
    global cnt
    global clients
    global ics_fileA
    global ics_fileB
    global json_fileA
    global json_fileB
    global CreatedDateA
    global CreatedDateB
    _.v.records = []
    ics_fileA=[]
    ics_fileB=[]
    json_fileA=[]
    json_fileB=[]
    epoch=None
    if _.switches.isActive('Epoch'):
        epoch=int(_.switches.values('Epoch')[0])
    for i,rec in enumerate( invoices ):
        for item in rec['Items']:
            if 'agreement' in item['code'].lower():
                svcs = process(item['description'],rec)
                y = svcs[0]
                svc = svcs[1]
                iid = rec['Id']
                invoices[i]['Client-Id'] = _clean.imp.app.record.inProfiles_7GzGHN(clients,rec=rec)
                created = _.autoDate(rec['CreatedDate'])
                rec['created']=created
                rec['Client-Id'] = invoices[i]['Client-Id']
                if epoch is None or created > epoch:
                    cal( y, svc, rec,iid=iid )
                # _.cp( rec['DocumentDate'], 'green' )
                # _.cp( [y,'YEAR'], 'yellow' )
                # _.pv(svc)
                if 0:
                    os.system('cls')
                    _.pr()
                    _.pr()
                    _.pr(rec['recID'])
                    _.pr(rec['DocumentDate'])
                    _.pr('___________________________________________________')
                    
                    # _.pr('code:',item['code'])
                    _.cp(item['code'],'yellow')
                    _.pr()
                    _.pr(item['description'])
                    ask=input(': ')
            # if True:
            # if rec['recID'] == 21:
            #   if _.showLine(item['code']):
            #       _.pr(item['code'])
            #       _.pr(item['description'])

    if 'misc' in _.v.do:
        if 1:
            _.pr( '', cnt )
        if 0:
            for k in svc_dic:
                _.pr( svc_dic[k].replace('.','') )

    pass

    CreatedDateV = {}
    CreatedDateV['CreatedDateA']=CreatedDateA
    CreatedDateV['CreatedDateB']=CreatedDateB
    # _.saveTable( CreatedDateV,'vps-hoth-7i0ZA-7GzGHN-invoices-calendar--CreatedDate.json' )
    if 'misc' in _.v.do:
        _.cp('vps-hoth-7i0ZA-7GzGHN-invoices-calendar--CreatedDate.json','cyan')

    pass
    if 'misc' in _.v.do:
        _.pr('A',len(json_fileA))
        _.pr('B',len(json_fileB))
        # _.linePrint(c='green')
        # _.pr('\n'.join(ics_fileA))

    if 'dic' in _.v.do:
        _.pv(_.v.records, d=1)
        # _.pr( _.addComma(len(_.v.records)) )
        if _.switches.isActive('SaveDate'):
            sd=_.switches.values('SaveDate')[0]
            dates=[]
            if os.path.isfile(sd):
                dates = _.getTable2(sd)
            tic0=int(time.time())
            tic1=_.friendlyDate(tic0).split(' ')[0]
            found=False
            for i,poo in enumerate(dates):
                tic2=_.friendlyDate(tic0).split(' ')[0]
                if tic1 == tic2:
                    found=True
            if not found:
                dates.append(tic0)

            _.saveTable2(dates,sd)
        pass
        if _.switches.isActive('SaveText'):
            for i, rec in enumerate(_.v.records):
                if 'files' in _.v.records[i]:
                    del _.v.records[i]['files']
            _.saveTable2(_.v.records,_.switches.values('SaveText')[0])

    pass

def load():
    global invoices
    global clients
    global calendar
    global CreatedDateA
    global CreatedDateB
    CreatedDateA=[]
    CreatedDateB=[]
    CreatedDate = _.getTable( 'vps-hoth-7i0ZA-7GzGHN-invoices-calendar--CreatedDate.json' )
    if CreatedDate:
        CreatedDateA=CreatedDate['CreatedDateA']
        CreatedDateB=CreatedDate['CreatedDateB']
    invoices = _.getTable2( _.switches.values('Files')[0] )
    calendar = _.getTable2( _.switches.values('Calendar')[0] )
    clients = {}
    for rec in _.getTable2( _.switches.values('Clients')[0] ):
        clients[ rec['Id'] ] = rec

_clean = _.regImp( __.appReg, 'record-cleaner' )








# #returns a String
# def __convert(data):
#     convStr = __convertTo(data)
#     convStr = __fields(convStr)
#     return convStr

# #convert JSON to a String
# def __convertTo(data):
#     str = "" + data
#     return str

# #takes string arg (prev converted from JSON) to split it into useful info
# def __fields(data)
#     #########
#     iCalStr = __iCalTemplate(title, dtStart, UID, remType, email)
#     return iCalStr

# #

def cal_data(epoch):
    e=_.autoDate(epoch)
    if not e:
        return 0
    try:
        return _.isDate( e,f='fdate' ).replace(' ','T').replace(':','').replace('-','')+'Z'
    except Exception as e:
        return 0
def cal_time_fix(epoch):
    hh=[]
    for n in range(15,20):
        hh.append(str(n))
    h=random.choice(hh)
    m=random.choice('00 15 30 45'.split(' '))
    return _.isDate( _.autoDate(epoch),f='fdate' ).split(' ')[0]+' '+h+':'+m+':00'

def cal_time_fix2(epoch):
    if not epoch:
        return epoch
    hh=[]
    for n in range(10,15):
        hh.append(str(n))
    h=random.choice(hh)
    m=random.choice('00 15 30 45'.split(' '))

    return _.isDate( _.autoDate(epoch),f='fdate' ).split(' ')[0]+' '+h+':'+m+':00'



def __iCalTemplate(title, dtStart, UID, email, remType=None, desc=None):
    dtStart=cal_time_fix(dtStart)
    if desc is None:
        desc=title
    # remType=None
    icsTempStr = "BEGIN:VEVENT\nDTSTART:" + cal_data(dtStart) + "\nDTEND:" + cal_data(_.autoDate(dtStart)+900) + "\nUID:" + UID + "\nDESCRIPTION:" + desc + "\nSUMMARY:" + title
    if not remType is None:
        icsTempStr += "\nBEGIN:VALARM\nACTION:" + remType + "DESCRIPTION:This is an event reminder"
        if remType == 'email':
            icsTempStr += "\nSUMMARY:Alarm notification\nATTENDEE:mailto:" + email
        icsTempStr += "\nEND:VALARM"
    icsTempStr=icsTempStr+'\n'+'END:VEVENT\n'
    return _str.do('all',icsTempStr,'00:00:00','14:30:00')
    # DTEND;VALUE=DATE:20080727



def dc(epoch):
    if not epoch > time.time():
        # _.pr('dc 0')
        return epoch
    d1=86390
    hh=[]
    for n in range(11,16):
        hh.append(str(n))
    h=random.choice(hh)
    m=random.choice('00 15 30 45'.split(' '))


    dow=_.isDate(epoch,f='dow')
    if dow == 'sun':
        epoch+=d1
    if dow == 'sat':
        epoch+=d1
        epoch+=d1
    bdate=_.isDate(epoch,f='date')+' '+h+':'+m+':00'
    epoch=_.isDate(bdate,f='epoch')
    # rint=_.isDate(bdate,f='fdate')
    # _.pr(rint)
    return epoch



import random

_.v=_.dot()
_.v.f='iso dow woy month epoch'
_.v.do=[
            # 'year',
            # 'misc',
            # 'ics',
            'dic',
]
# _.pr(_.v.do)
# sys.exit()


'''
check battery
run generator in manual mode to heat up oil
oil change includes oil filter and plugs all material install and tax included in this package call the office with any questions at
change out to briggs & stratton full synthetic oil
check air filter change if needed
change spark plugs at manufacturers recommended time on briggs & stratton motor
check generator board
check fuses on board
check generator tap for voltage
check generator tap for hertz
check grounding bonds
check oil
check boards in transfer switch
check transfer switch main fuses for utility
check boards in transfer switch
cut off main breaker to utilities in transfer switch wait for generator to start test
wait for transfer switch to transfer over from utilities to generator to complete transfer switch test
turn back main breaker for utilities and transferred back
wait for generator too go through cool down cycle and turn off
generator is in auto to complete major service
turn back on utilities and transfer switch to watch utilities transferred back off generator watch generator go through cool down cycle and turn off
check all controls
programming of generator
top off the antifreeze
along with disposal of all oil and oil filters for recycle
start up of generator
programming of generator
new air intake foam ring
new rubber intake tube
'''


# t=_.epoch_times()
# _.pv(t)
# sys.exit()


#START
# from icalendar import vDatetime



########################################################################################
if __name__ == '__main__':
    action()
    __.isExit()





