0

Parsing RSS Date in Brightscript

I am trying to write a script to parse a date from an RSS feed into a different format.

It comes in "1/1/20 1:00:00 PM"

I want it to read "Wednesday, January 1 | 1:00 PM"

 

I am trying the following, but not sure if I am off base here with the language:

 

Sub hcrss5(xmlFileName$ as String, itemsByIndex as object, itemsByTitle as Object, userVariables As Object)

xml = CreateObject("roXMLElement")
if not xml.Parse(ReadAsciiFile(xmlFileName$)) then
print "xml read failed"
else

dateTime$ = itemXML.pubdate.GetText()
dateTimeParsed$ = DateTime.parse(dateTime$, "DDDD/MMMM D/YYYY"+" | "+"hh:mm A")

if type(xml.channel.item) = "roXMLList" then
index% = 0
for each itemXML in xml.channel.item
itemsByIndex.push(itemXML.title.GetText())
itemsByIndex.push(itemXML.datetimeparsed$.GetText())
itemsByIndex.push(itemXML.calendar.GetText())
itemsByIndex.push(itemXML.description.GetText())
itemsByIndex.push(itemXML.location.GetText())
index% = index%+1
next
endif
endif

DeleteFile(xmlfilename$)
end Sub

3 comments

  • 0
    Avatar
    Bright Scripters info[at]brightscripters.com

    Please help us help you.

    Were you able to get this parser to work with your application at all?

    Are you need help with formatting the date only, or with getting this parser to function?

  • 0
    Avatar
    Hunts

    This one kills it altogether. I have to figure another avenue.

    Is the language wrong?

     

    It was working before I added

    dateTime$ = itemXML.pubdate.GetText()
    dateTimeParsed$ = DateTime.parse(dateTime$, "DDDD/MMMM D/YYYY"+" | "+"hh:mm A")

    I am just trying to get the date to show in the format in the first post,  it comes in DD/MM/YY

    or can I do something directly in the push line like this -

    itemsByIndex.push(Date <DDDD/MMMM D/YYYY>+" | "+<hh:mm A>(itemXML.pubdate.GetText()))

     

    It was my understanding it had to be defined prior to pushing, but I don' write this stuff.

     

    Thanks,

    Scott

  • 0
    Avatar
    Bright Scripters info[at]brightscripters.com

    In this line 

    DateTime.parse(dateTime$, "DDDD/MMMM D/YYYY"+" | "+"hh:mm A")

     

    There is reference to an object named DateTime, which is not instantiated as far as I can tell.

    You'd need to instantiate an object like so:

    DateTime = CreateObject("roDateTime")

    And use methods found here, to construct the format 

    https://docs.brightsign.biz/display/DOC/roDateTime

     

Please sign in to leave a comment.