hgh

Thursday, 11 March 2010

GMT/UTC standards reversed in timezone standards (and PHP, and wordpress, and Unix/Posix)

Well, software never stops surprising me.

Working on a new project which involves PHP and timezones, I obviously needed to use these PHP supported timezone standards. No problem when I set a timezone to a specific standard location (i.e. ‘America/New_York’), but when using the non-recommended GMT standards, the resulting time was reversed. So, by selecting GMT-5, the America East Coast time, the clock gave me GMT+5 time, something like the time in Uzbekistan (Asia) :-D .

In other words, time ahead of Europe/Greenwich, not behind as if GMT standards signs were reversed.

Now, after double checking the code and some :-x , I found the following:

directly from wikipedia’s Timezone aka TZ database page:

“Additionally a special area of Etc is used for some administrative zones (…). In order to conform with the POSIX style, those zones beginning with “Etc/GMT” have their sign reversed from what most people expect. In this style, zones west of GMT have a positive sign and those east have a negative sign.”

So, yes GMT (aka UTC) standards are reversed in the timezone standard database. I do not know how the “POSIX style” might justify such a confusion, maybe a nerd “stumbling upon” can write POSIX’s very good reasons in my comments ;-)

Not for nothing, the php.net site recommends NOT to use the Etc/GMT standards and wordpress administration page, in Setting -> General -> Timezone field doesn’t show the resulting “local time” by selecting UTC+10 or UTC-5 (unlike what happens by selecting a geographical timezone location).

What I did in my drop-down menu was reversing the signs between the values in the <option> tags and the displayed strings, and added a lengthy comment in the source code.

Well, I hope this helps someone else struggling with the same issue, at least.

Wednesday, 10 March 2010

RSS Just Better plugin 0.1 released

Again a bit of a late announcement, but i released a new plugin. It’s similar to my previously released plugin Google News Widget & Shortcode but this time the user can link any external RSS feed of their choice.

Yes, it’s mocking the native “RSS widget”for wordpress as they will displayed close to each other so you have the RSS widget and another RSS widget “Just better”.

I have created a page on this blog for that plugin too: please take a look.

Google News Widget plugin 0.6 released

A belated announcement, but a new version of my plugin has been released last Saturday.

From the readme file:

== Changelog ==

= 0.6 =

  • added excerpt option to the widget form/shortcode
  • added number of excerpt chars to be displayed on the widget form/shortcode
  • added working message about formatting and sidebars
  • updated readme.txt

== Upgrade Notice ==

= 0.6 =

  • if you want to show Google’s excerpt then upgrade to version 0.6. Please do not use on narrow sidebars as it contains images and formatting.

A very

big

warning: if you select the excerpt, ensure not to use it in a narrow sidebar: the formatting would not give you a nice view out of the Google’s news you choose.

Tuesday, 2 March 2010

Still about languages and countries codes.

Working on a new plugin, I have made the following “discovery”:

As we all know, WordPress has been technically built to be translated in different languages.

The naming convention used to identify the language, is based on the ISO-639 language code (e.g. pt for Portuguese) followed by the ISO-3166 country code (e.g. _PT for Portugal or _BR for Brazil).

Complete lists of codes can be found at the GNU website: country codes and language codes.

But also at the ISO Standards website at: ISO 3166-1 and ISO 639-2 webpages and on wikipedia: country codes list and language codes list.

The naming convention used to identify the languages in wordpress is curiously idenitcal used by Google News to localize its news as showed in the table in my previous post.

Wonders of the Internet

I really owe a special mention to Elmar Friebe, early adopter of my google-news-widget wordpress plugin.

He was so keen in using it on his blog, that didn’t get disheartened by the quirks of version 0.3. He helped me in testing a fix when I still did not get a clue of what was going on and hey, it worked! I mean, the cooperation worked and the fix too. :-)

That’s one of the wonders of the Internet: getting to know special strangers, who do special things for you and suddenly, you realise they are not any longer strangers!

I should be used to this by now, after 16 years of living the Internet, but it still amazes me sometimes.

Nice to meet you, Elmar!

Thursday, 25 February 2010

Google News Widget wp plugin 0.5 released

Version 0.2/0.3 went wrong: on certain blogs (but not on those I tested it with) prevented the administration page from working. A kind user of my blog helped to test it as – no way was it going to happen on my blogs.

It was a newbie mistake. Sorry for any inconvenience caused.

Hopefully this has been fixed, a new version has been created again.

From the readme.txt file:

Description:

It displays the list of the latest news by Google News given localization (country-language), search word(s) or topic, number of displayable news and whether you want publication date, time, reference to the author displayed/not. The look & feel is customizable too. It works as a widget or shortcode (in post/pages). In other words, you can show your news in any widget-ready area of your wordpress blog or any post/page of your choice.

Usage:

As a widget:

  • Drag & Drop your widget in the widget-ready area
  • Choose a title to be given to this news list
  • Choose the location of the news you wish to display
  • Select either the topic you need to cover or search word(s) (if you define both, the search keys will be ignored)
  • Select whether you want a publication date/time or reference to the author displayed/not
  • Select whether you want a bullet-point/dotted list (default) or a numbered/ordered list
  • Select whether you want the linked news pages to open up in a new page (default) or in the same page.
  • Click on ‘Save’ (and Close, if you want)

As a shortcode:

That’s the sole mandatory attribute. Optional attributes are:

  • search: search-words according to google search syntax (see the description above) (default: none)
  • topic: any of Google’s topic-codes (default: Top Stories). Here is the list of Google’s topics.
  • num: number of news to be displayed (default: 3)
  • list: either “UL” or “OL” to get unordered or ordered lists
  • target: either “_blank” or “_self” to get links opened in a new/the same windows.
  • pubdate: either true or false to display the publication date/not;
  • pubtime: either true or false to display the publication time/not;
  • pubauthor: either true or false to display a link to the author/not;

Example:

powered by Google News Just Better 1.2 plugin

Please note the following Google quirks:

  1. Not all topics are set for all country/language. If you select a topic for a country where this is not provided (by Google) then the “Top stories” (the default) will be displayed instead.
  2. Google (not me!) allows to search by topic OR by search-word(s). The two “filters” cannot apparently work together (i.e. you cannot search for “hockey” in topic “Sport”).
  3. Because of the above, if topic AND search-keys are both indicated, then the search-keys are ignored (but no, no error message).
  4. The search syntax is that indicated by Google. In other words, if in the search results:
    • all the words need to be present, then enter space-separated words (word1 word2 etc);
    • any of the words can be present, then enter words separated by OR (word1 OR word2);
    • the exact phrase needs to be present, then enter the phrase delimited by double quotes (“exact phrase”).
  5. The maximum number of displayable articles depends on the number of articles stored into the XML page (RSS feed page) of Google news website (i.e. if you wish to display the latest 15 news and the XML page contains 10 news only, then only 10 will be displayed).

Sunday, 21 February 2010

Google News topic codes

This table is to be used with Google News Wizard plugin when used as a shortcode. Attribute topic needs to be one of the following:

Codes Topics
Top Stories
w World
n Nation
b Business
t Sci/Tech
e Entertainment
s Sport
m Health
ir Spotlight
po Most Popular

Google News localization codes

This table is to be used with Google News Wizard plugin when used as a shortcode. Attribute location need to be one of the following.

Note: Country codes do not always correspond to the ISO country codes as some countries are combined with the language the news are written into (in many countries more than one language is spoken).

Codes Countries
es_ar Argentina
au Australia
nl_be België
fr_be Belgique
en_bw Botswana
pt-BR_br Brasil
ca Canada English
fr_ca Canada Français
cs_cz Ceská republika
es_cl Chile
es_co Colombia
es_cu Cuba
de Deutschland
es España
es_us Estados Unidos
en_et Ethiopia
fr France
en_gh Ghana
in India
en_ie Ireland
en_il Israel English
it Italia
en_ke Kenya
hu_hu Magyarország
en_my Malaysia
es_mx México
en_na Namibia
nl_nl Nederland
nz New Zealand
en_ng Nigeria
no_no Norge
de_at Österreich
en_pk Pakistan
es_pe Perú
en_ph Philippines
pl_pl Polska
pt-PT_pt Portugal
de_ch Schweiz
fr_sn Sénégal
en_sg Singapore
en_za South Africa
fr_ch Suisse
sv_se Sverige
en_tz Tanzania
tr_tr Türkiye
uk U.K.
us U.S.
en_ug Uganda
es_ve Venezuela
vi_vn Vit NamVietnam
en_zw Zimbabwe
el_gr daGreece
ru_ru Russia
ru_ua Ukraine
uk_ua Ukraine
iw_il Israel
ar_ae UAE
ar_sa KSA
ar_me Arabic
ar_lb Lebanon
ar_eg Egypt
hi_in India
ta_in India
te_in India
ml_in India
kr Korea
cn China
tw Taiwan
jp Japan
hk Hong Kong

Google News Widget wp plugin 0.2/0.3 released

Thanks for your kind feedback.

Yes, a new version has been created again. From the readme file:

Description:

With this plugin, you can display a list of the latest news (by Google News) given localization (country/language), search word(s) or topic and the number of latest news you want to show. The list look & feel is customizable too. It works as a widget or shortcode (in post/pages), so you can show your news in any widget-ready are of your wordpress blog or any post or page of your choice.

Usage:

As a widget:

  • Drag & Drop your widget in the widget-ready area
  • Choose a title to be given to this news list
  • Choose the location of the news you wish to display
  • Select either the topic you need to cover or search word(s) (if you define both, the search keys will be ignored)
  • Select whether you want a dotted list (default) or a numbered/ordered list
  • Select whether you want the linked news pages to open up in a new page (default) or in the same page.
  • Click on ‘Save’ (and Close, if you want)

As a shortcode:

  • In Posts/Pages->Add New/Edit of your wp admin page, select HTML in the entry form
  • enter [gnews location="xx"]
    where xx is any Google’s location-code of the news you wish to display. A list of Google’s localization codes is here.

That’s the sole mandatory attribute. Optional attributes are:

  • search: search-words according to google search syntax (read more below) (default: none)
  • topic: any of Google’s topic-codes (default: Top Stories). Here is the list of Google’s topics.
  • num: number of news to be displayed (default: 3)
  • list: either “UL” or “OL” to get unordered or ordered lists
  • target: either “_blank” or “_self” to get links opened in a new/the same windows.

Example: [gnews location="es" topic="" search="sport" topic="e" num="8" list="UL" target="_self"]

Please note the following Google quirks:

  1. Not all topics are set for all country/language.  If you select a topic for a country where this is not provided (by Google) then the “Top stories” (the default) will be displayed instead.
  2. Google (not me!) allows to search by topic OR by search-word(s). The two “filters” cannot apparently work together (i.e. you cannot search for “hockey” in topic “Sport”).
  3. Because of the above, if topic AND search-keys are both indicated, then the search-keys are ignored (but no, no error message).
  4. The search syntax is that indicated by Google. In other words, if in the search results:
    • all the words need to be present, then enter space-separated words (word1 word2 etc);
    • any of the words can be present, then enter words separated by OR (word1 OR word2);
    • the exact phrase needs to be present, then enter the phrase delimited by double quotes (“exact phrase”).
  5. The maximum number of displayable articles depends on the number of articles stored into the XML page (RSS feed page) of Google news website (i.e. if you wish to display the latest 15 news and the XML page contains 10 news only, then only 10 will be displayed).

Monday, 15 February 2010

Google News Widget wordpress plugin released

This is my first released wordpress plugin.

For the readme.txt file.

This plugin creates a widget which displays an unordered list of links to the latest google news, given one or more keywords.
The user can customize the list by choosing: the localization (country/language) of the news and the number of articles to be displayed.

Note 1: The syntax for the search criteria is that indicated by Google:

  • all the words need to be present: key1 key2 key3 (separate the words with a space)
  • the exact phrase needs to be present: “exact phrase” (delimit with double quotes)
  • any of the words can be present: key1 OR key2 OR key3 (write an OR among the words).

Note 2: The maximum number of displayable articles depends on the number of articles stored into the XML page (RSS feed page) of Google news website.
If you wish to display the latest 15 news and the XML page contains 10 news only, then only 10 will be displayed.

You can find the plugin on this server here: google-news-widget.

Comments are welcome.