2

I would like to convert dates in the format like 24 february 2014 to proper RSS pubDate format (actually february on my pages is written in Russian). I have the following code to create own RSS -

XPath Fetch Page

URL: http://www.tcsbank.ru/about/news-archive/
Extract Using XPath: //li[@class='news-list__item']
Use HTML5 parser: yes

Loop

For each *item* in input field
  ...
  PubDate: item.span
emit *all* results

Loop

For each *item.pubDate*
  Replace
  first * january * with *.01.*
  first * february * with *.02.* 
  ...
assign results to *item.pubDate*

In result, my pubDate contains value in the format DD.MM.YYYY (and works only for first 10 months since Replace supports 10 replacements only). Which is still invalid date.

How should I fix that?

LA_
  • 19,823
  • 58
  • 172
  • 308

1 Answers1

2

You could add one more loop just like the last one, to finish up the remaining months:

For each *item.pubDate*
  Replace
  first * november * with *.11.*
  first * december * with *.12.* 
  ...
assign results to *item.pubDate*

But an even easier solution is to use Regex instead of Loop for this:

in item.pubDate replace january with 01
in item.pubDate replace february with 02
...

and again, create a second Regex for the last two months. (same max 10 entries limitation)

Finally, to convert these now numeric dates to a different date format, you can use a Regex replacement like this:

in item.pubDate replace (\d\d)\.(\d\d)\.(\d{4}) with $3-$2-$1

This will convert DD.MM.YYYY format to YYYY-MM-DD format. If you need slightly different format, adjust the expression appropriately.

UPDATE

I cloned your original pipe and did what I could:

http://pipes.yahoo.com/pipes/pipe.info?_id=cda36fe2b6f05160860c30bf1f0ece06

... unfortunately, it still doesn't work: the RSS view still doesn't include pubDate, even though I converted it to a proper DateTime object. It's also strange that the pipe's page shows warnings at first, that something is not a proper DateTime object, but then the view changes and it shows the feed entries correctly. I don't understand what is not a proper DateTime object there.

Yahoo Pipes is buggy. Many things that should work don't work, but sometimes there's a workaround. Maybe you'll find one for this if you play with it long enough. But maybe not. Good luck in any case.

janos
  • 120,954
  • 29
  • 226
  • 236
  • Thanks. But still the main problem - text DD.MM.YYYY instead of datetime - is not fixed... – LA_ Feb 26 '14 at 05:36
  • janos, your approach helps to change the date format (to date like 2014-04-3), but still it is not recognized as proper datetime and hence not propagated to RSS. – LA_ Mar 04 '14 at 11:59
  • @LA_ if you tell me the exact format you need and the input text you have, maybe I can fix it. I don't really know what you mean it's not recognized as proper datetime. By what? Your RSS client? What do you use to check if the date is in "proper format" or not? I need a way to test exactly as you do, otherwise it's hard to see the problem. – janos Mar 04 '14 at 12:40
  • the input text is given in the original question, it is `http://www.tcsbank.ru/about/news-archive/`. As result I should get RSS with `pubDate` element for each item. But there is no `pubDate` - see RSS result http://pipes.yahoo.com/pipes/pipe.run?_id=189b3f3fa38d7ffd242bbae15738c642&_render=rss (hope, the link will work for you). I assume that this is because of wrong format date passed. See also what I have now - http://goo.gl/6H1WLg, http://goo.gl/pgIw5v – LA_ Mar 04 '14 at 16:46
  • Thanks @LA_... I hope you'll find a way to make it work! – janos Mar 17 '14 at 13:44