
import twccommon
import time
import twc.dsmarshal as dsm

#areaList = wxdata.getUGCInterestList('72744000', 'coopId')
#twccommon.Log.info(areaList)

twccommon.Log.info("RWE - Daypart forecast is being sent.")
#if not areaList:
#    abortMsg()

Y, M, D, h, m, s, wd, jd, dst = time.localtime(time.time())
dOffset = 0  # Always use offset of 0

keyTime = time.mktime((Y, M, D + dOffset, 5, 0, 0, 0, 0, -1))

numDayparts = 4

times = [
    keyTime,
    keyTime + (12 * 3600),
    keyTime + (24 * 3600),
    keyTime + (36 * 3600)
]


forecastTime_1_1 = int(keyTime + (1 * 12 * 3600))
b_1_1 = twc.Data()

b_1_1.phrase = 'Partly cloudy this evening, then becoming cloudy after midnight. Low 36F. Winds NE at 5 to 10 mph.'
b_1_1.skyCondition = 2700
b_1_1.temp = 36
b_1_1.daypartName = "Tonight"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_1_1,
    validTime=forecastTime_1_1,
    numDayparts=4,
    expiration=int(int(keyTime + (1 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_1_1))

forecastTime_1_2 = int(keyTime + (2 * 12 * 3600))
b_1_2 = twc.Data()

b_1_2.phrase = 'Cloudy early with periods of light rain and snow later in the day. High 41F. Winds NE at 10 to 20 mph. Chance of rain 70%.'
b_1_2.skyCondition = 7403
b_1_2.temp = 41
b_1_2.daypartName = "Tomorrow"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_1_2,
    validTime=forecastTime_1_2,
    numDayparts=4,
    expiration=int(int(keyTime + (2 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_1_2))

forecastTime_2_1 = int(keyTime + (3 * 12 * 3600))
b_2_1 = twc.Data()

b_2_1.phrase = 'Rain and snow in the evening turning windy with snow late. Low 32F. Winds NE at 20 to 30 mph. Chance of precip 100%. Snow accumulating 1 to 3 inches.  Winds could occasionally gust over 40 mph.'
b_2_1.skyCondition = 510
b_2_1.temp = 32
b_2_1.daypartName = "Tomorrow night"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_2_1,
    validTime=forecastTime_2_1,
    numDayparts=4,
    expiration=int(int(keyTime + (3 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_2_1))

forecastTime_2_2 = int(keyTime + (4 * 12 * 3600))
b_2_2 = twc.Data()

b_2_2.phrase = 'Periods of snow and windy. High near 35F. Winds N at 25 to 35 mph. Chance of snow 100%. 5 to 8 inches of snow expected.  Winds could occasionally gust over 50 mph.'
b_2_2.skyCondition = 1610
b_2_2.temp = 35
b_2_2.daypartName = "Wednesday"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_2_2,
    validTime=forecastTime_2_2,
    numDayparts=4,
    expiration=int(int(keyTime + (4 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_2_2))

forecastTime_3_1 = int(keyTime + (5 * 12 * 3600))
b_3_1 = twc.Data()

b_3_1.phrase = 'Windy. Snow in the evening will transition to snow showers overnight. Low 26F. Winds NNW at 25 to 35 mph. Chance of snow 90%. 1 to 3 inches of snow expected.  Heavier amounts in persistent snowbands.'
b_3_1.skyCondition = 1610
b_3_1.temp = 26
b_3_1.daypartName = "Wednesday night"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_3_1,
    validTime=forecastTime_3_1,
    numDayparts=4,
    expiration=int(int(keyTime + (5 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_3_1))

forecastTime_3_2 = int(keyTime + (6 * 12 * 3600))
b_3_2 = twc.Data()

b_3_2.phrase = 'Cloudy and windy with on and off snow showers mainly during the morning. High 28F. Winds NNW at 20 to 30 mph. Chance of snow 40%.  Higher wind gusts possible.'
b_3_2.skyCondition = 6813
b_3_2.temp = 28
b_3_2.daypartName = "Thursday"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_3_2,
    validTime=forecastTime_3_2,
    numDayparts=4,
    expiration=int(int(keyTime + (6 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_3_2))

forecastTime_4_1 = int(keyTime + (7 * 12 * 3600))
b_4_1 = twc.Data()

b_4_1.phrase = 'Overcast. Low 22F. Winds NNW at 15 to 25 mph.  Higher wind gusts possible.'
b_4_1.skyCondition = 2600
b_4_1.temp = 22
b_4_1.daypartName = "Thursday night"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_4_1,
    validTime=forecastTime_4_1,
    numDayparts=4,
    expiration=int(int(keyTime + (7 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_4_1))

forecastTime_4_2 = int(keyTime + (8 * 12 * 3600))
b_4_2 = twc.Data()

b_4_2.phrase = 'Cloudy. High around 25F. Winds NW at 10 to 20 mph.'
b_4_2.skyCondition = 2600
b_4_2.temp = 25
b_4_2.daypartName = "Friday"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_4_2,
    validTime=forecastTime_4_2,
    numDayparts=4,
    expiration=int(int(keyTime + (8 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_4_2))

forecastTime_5_1 = int(keyTime + (9 * 12 * 3600))
b_5_1 = twc.Data()

b_5_1.phrase = 'Overcast. Low 22F. Winds NW at 5 to 10 mph.'
b_5_1.skyCondition = 2600
b_5_1.temp = 22
b_5_1.daypartName = "Friday night"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_5_1,
    validTime=forecastTime_5_1,
    numDayparts=4,
    expiration=int(int(keyTime + (9 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_5_1))

forecastTime_5_2 = int(keyTime + (10 * 12 * 3600))
b_5_2 = twc.Data()

b_5_2.phrase = 'Cloudy. High 28F. Winds WNW at 5 to 10 mph.'
b_5_2.skyCondition = 2600
b_5_2.temp = 28
b_5_2.daypartName = "Saturday"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_5_2,
    validTime=forecastTime_5_2,
    numDayparts=4,
    expiration=int(int(keyTime + (10 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_5_2))

forecastTime_6_1 = int(keyTime + (11 * 12 * 3600))
b_6_1 = twc.Data()

b_6_1.phrase = 'Cloudy. Snow showers developing after midnight. Low 23F. Winds NNW at 5 to 10 mph. Chance of snow 40%. Snow accumulations less than one inch.'
b_6_1.skyCondition = 7800
b_6_1.temp = 23
b_6_1.daypartName = "Saturday night"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_6_1,
    validTime=forecastTime_6_1,
    numDayparts=4,
    expiration=int(int(keyTime + (11 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_6_1))

forecastTime_6_2 = int(keyTime + (12 * 12 * 3600))
b_6_2 = twc.Data()

b_6_2.phrase = 'Variable clouds with snow showers. High 27F. Winds NW at 10 to 15 mph. Chance of snow 50%. 1 to 3 inches of snow expected.'
b_6_2.skyCondition = 1400
b_6_2.temp = 27
b_6_2.daypartName = "Sunday"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_6_2,
    validTime=forecastTime_6_2,
    numDayparts=4,
    expiration=int(int(keyTime + (12 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_6_2))

forecastTime_7_1 = int(keyTime + (13 * 12 * 3600))
b_7_1 = twc.Data()

b_7_1.phrase = 'Snow showers. Low around 15F. Winds NW at 10 to 20 mph. Chance of snow 60%. Snow accumulating 1 to 3 inches.'
b_7_1.skyCondition = 1400
b_7_1.temp = 15
b_7_1.daypartName = "Sunday night"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_7_1,
    validTime=forecastTime_7_1,
    numDayparts=4,
    expiration=int(int(keyTime + (13 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_7_1))

forecastTime_7_2 = int(keyTime + (14 * 12 * 3600))
b_7_2 = twc.Data()

b_7_2.phrase = 'Cloudy with snow showers mainly during the morning. High 18F. Winds NW at 10 to 20 mph. Chance of snow 40%. Snow accumulations less than one inch.'
b_7_2.skyCondition = 6803
b_7_2.temp = 18
b_7_2.daypartName = "Monday"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_7_2,
    validTime=forecastTime_7_2,
    numDayparts=4,
    expiration=int(int(keyTime + (14 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_7_2))

forecastTime_8_1 = int(keyTime + (15 * 12 * 3600))
b_8_1 = twc.Data()

b_8_1.phrase = 'Cloudy. Low around 10F. Winds WNW at 10 to 20 mph.'
b_8_1.skyCondition = 2600
b_8_1.temp = 10
b_8_1.daypartName = "Monday night"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_8_1,
    validTime=forecastTime_8_1,
    numDayparts=4,
    expiration=int(int(keyTime + (15 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_8_1))

forecastTime_8_2 = int(keyTime + (16 * 12 * 3600))
b_8_2 = twc.Data()

b_8_2.phrase = 'Overcast. High 21F. Winds W at 10 to 20 mph.'
b_8_2.skyCondition = 2600
b_8_2.temp = 21
b_8_2.daypartName = "Tuesday"

wxdata.setDaypartData(
    loc='72744000',
    type='textFcst',
    data=b_8_2,
    validTime=forecastTime_8_2,
    numDayparts=4,
    expiration=int(int(keyTime + (16 * 12 * 3600)) + 43200)
)
twccommon.Log.info("RWE - Daypart forecast set for 72744000 at " + str(forecastTime_8_2))
