Niculskin - Date and time Formatting.

451 views
Skip to first unread message

John Rye

unread,
Jan 21, 2017, 4:24:08 AM1/21/17
to weewx-user
Hi All,

A while ago I installed Nico Gulen's Niculskin and overall I'm really
happy with it. (http:/newall-wx.gen.nz)

However ... (isn't there always one or two of these <grin>)

However #1: How or where are the date and time displays actually
configured?

It appears to me that the settings in both /etc/weewx/weewx.conf
and /etc/weewx/skins/niculskin/skin.conf are being ignored.

This can be seen in the site where all dates are displayed in
month-day-year format and and times in 12-hour format.

I have attached both /etc/weewx/weewx.conf and niculskin/skin.conf.

Cheers

John in NZ

skin.conf
weewx.conf

Darryn Capes-Davis

unread,
Jan 21, 2017, 7:08:11 AM1/21/17
to weewx-user
John,

What locale is your server? I ask as the only way you would be getting the display on your site would be from the format string "%x %X" on a US locale server.

However I can't see how the format "%x %X" would be being used?

Darryn

John Rye

unread,
Jan 21, 2017, 9:56:30 AM1/21/17
to weewx-user


On Sunday, 22 January 2017 01:08:11 UTC+13, Darryn Capes-Davis wrote:
John,

> What locale is your server?

[lists@amd64 ~]$ locale
LANG=en_NZ.UTF-8
LC_CTYPE="en_NZ.UTF-8"
LC_NUMERIC="en_NZ.UTF-8"
LC_TIME="en_NZ.UTF-8"
LC_COLLATE="en_NZ.UTF-8"
LC_MONETARY="en_NZ.UTF-8"
LC_MESSAGES="en_NZ.UTF-8"
LC_PAPER="en_NZ.UTF-8"
LC_NAME="en_NZ.UTF-8"
LC_ADDRESS="en_NZ.UTF-8"
LC_TELEPHONE="en_NZ.UTF-8"
LC_MEASUREMENT="en_NZ.UTF-8"
LC_IDENTIFICATION="en_NZ.UTF-8"
LC_ALL=
[lists@amd64 ~]$

  So physically in New Zealand as is the server.
 
> I ask as the only way you would be getting the display on your site would be from the format string "%x %X" on a US locale server.

 Agreed. However I have altered all the time format strings in weewx.conf in line with what is shown in http://weewx.com/docs/customizing.htm#Units_TimeFormats. I don't see any point in going further and custominsing as per strftime - it shouldn't be necessary


> However I can't see how the format "%x %X" would be being used?

I'm beginning to wonder if its hard-coded in the javascript (/me shudders) because I'm fairly sure I was able to alter the formatting in the Standard skin.

Cheers

John in NZ

John Rye

unread,
Jan 21, 2017, 10:27:06 AM1/21/17
to weewx-user


On Sunday, 22 January 2017 03:56:30 UTC+13, John Rye wrote:


And replying to self ...

Reverted to Standard skin ... Guess what?  Dates are in dd/mm/yy format

The "problem" does not seem to lay with Weewx  but with underlaying code in the Nico's skin somehow ignoring or overriding weewx.conf.

A pity because I really like that skin ...

John in NZ

gjr80

unread,
Jan 21, 2017, 10:12:28 PM1/21/17
to weewx-user
John,

I was intrigued as niculskin is not that complex and in its index.html.tmpl template it just uses plain $current.dateTime (line 39) to display 'Last updated'. So it should be respecting the standard date/time formats in niculskin/skin.conf (there are no overrides in weewx.conf - unless the user had some there before the niculskin install). Still intrigued I fired up a debain VM running weewx/simulator and installed niculskin using wee_extension. I don't know whether you encountered any runtime errors after install but I had to (1) manually install the skins/niculskin/RSS directory and (2) edit niculskin/skin.conf and under [niculskinLabels] [[conditions]] I had to change extra_1_temp_humidity to extra1_temp_humidity and extra_2_temp_humidity to extra2_temp_humidity. None of these should affect date-time formats though.

When run out of the box (with the aforementioned changes and language =  in niculskin/skin.conf) the 'Last updated' line in index.html was (sorry VM is not publicly accessible):

<p><i class="fa fa-clock-o" ></i> Last updated 22/01/17 12:50:00</p>

When I make the following change to /niculskin/skin.conf:

[Units]
   
[[TimeFormats]]
        current
= %d %b %Y

I get:

<p><i class="fa fa-clock-o" ></i> Last updated 22-Jan-2017 12:40</p>

As it should be. Not that it matters but my locale is coming up AU:

LANG=en_AU.UTF-8
LANGUAGE
=en_AU:en
LC_CTYPE
="en_AU.UTF-8"
LC_NUMERIC
="en_AU.UTF-8"
LC_TIME
="en_AU.UTF-8"
LC_COLLATE
="en_AU.UTF-8"
LC_MONETARY
="en_AU.UTF-8"
LC_MESSAGES
="en_AU.UTF-8"
LC_PAPER
="en_AU.UTF-8"
LC_NAME
="en_AU.UTF-8"
LC_ADDRESS
="en_AU.UTF-8"
LC_TELEPHONE
="en_AU.UTF-8"
LC_MEASUREMENT
="en_AU.UTF-8"
LC_IDENTIFICATION
="en_AU.UTF-8"
LC_ALL
=

Seems to me that everything is working as it should, I cannot find fault with niculskin. Personally I don't like making the change skin = niculskin under [StdReport] [[StandardReport]] in weewwx.conf as the [[StandardReport]] will tend to lead some people to skins/Standard/skin.conf (rather than skins/niculskin/skin.conf) if they want to change something like a date or time format but again that is just an ease of use issue and would not change the date-time format.

I'll give it some more thought but I am tending to think it is something peculiar to your install.

Gary

Carlingford Weather

unread,
Jan 21, 2017, 10:19:06 PM1/21/17
to gjr80, weewx-user

John,

 

A thought. Are you using wee_reports external or just allowing weewx to generate the reports per archive interval?

 

Darryn

--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/lOgABRVqDcs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

gjr80

unread,
Jan 21, 2017, 11:07:11 PM1/21/17
to weewx-user
You did stop/start or reload weewx after making changes to weewx.conf? Not required for changes to skin.conf but is required for weewx.conf changes.

Gary

Darryn Capes-Davis

unread,
Jan 22, 2017, 3:33:23 AM1/22/17
to weewx-user
John,

I have done a bit of thinking and testing on my Ubuntu setup. Three things here.

1. Missing LC_ALL is an issue. Find your favourite information to fix on Google.
2. Missing LC_ALL will mean "%x %X" will give what you are seeing on index.html
3. I expect that Niculskin code for localising strings is giving havoc to weewx ConfigObj code and making weewx.conf override skin.conf (just a guess).

Fixes?

A. Fix LC_ALL (Looks like setting in /etc/environment is best bet). Can test by running in python interpreter .
You will see for me, where I also have the LC_ALL issue, I get the wrong format with "%x %X", even though the rest of my LC_X and en_AU.
>>> import datetime
>>> datetime.datetime.now().strftime("%x %X")
'01/22/17 19:16:00'

 B. Since you don't need Niculskin localisation, you can not use the Niculskin binaries CheetahGeneratorTranslated. Revert back to weewx.cheetahgenerator.CheetahGenerator.

Good luck.

Cheers

Darryn

Darryn Capes-Davis

unread,
Jan 22, 2017, 4:45:21 AM1/22/17
to weewx-user
John,

A bit more. LC_ALL should be left alone, but a python program should set the locale. (See http://askubuntu.com/questions/795455/python-default-locale-is-not-working)

That advice works for me in a python interpreter

>>> import locale
>>> locale.setlocale(locale.LC_ALL,'')
'en_AU.UTF-8'

>>> import datetime
>>> datetime.datetime.now().strftime("%x %X")
'22/01/17 20:35:56'

I note that weewx code for 3.7 has the engine run the setlocale() statement. (Tom, was this to fix an issue like this or?... I note that the commit says to just report the locale but it does more than that).

Cheers

Darryn

gjr80

unread,
Jan 22, 2017, 6:11:25 AM1/22/17
to weewx-user
As far as I was aware the reason locale.setlocale(locale.LC_ALL) was added to engine.py was to merely log the in-use locale during startup since there has been an increasing number of locale related issues from users. I was of the understanding that locale.setlocale(locale.LC_ALL) does not set anything, rather it merely returns the setting for the locale.LC_ALL category. user/extensions.py sets locale via locale.setlocale(locale.LC_ALL, '') which appears to be the accepted method of setting locale in python.

Gary

Carlingford Weather

unread,
Jan 22, 2017, 6:19:05 AM1/22/17
to weewx...@googlegroups.com
Ah yes. Engine is not setting it. However, it would seem that there may be a valid reason to do so? I must say I can not 100% understand my ubuntu setup and why python does need to be primed, and does not seem to have the system default available it python.

From: weewx...@googlegroups.com <weewx...@googlegroups.com> on behalf of gjr80 <gjrod...@gmail.com>
Sent: Sunday, January 22, 2017 10:11:25 PM

To: weewx-user
Subject: [weewx-user] Re: Niculskin - Date and time Formatting.
As far as I was aware the reason locale.setlocale(locale.LC_ALL) was added to engine.py was to merely log the in-use locale during startup since there has been an increasing number of locale related issues from users. I was of the understanding that locale.setlocale(locale.LC_ALL) does not set anything, rather it merely returns the setting for the locale.LC_ALL category. user/extensions.py sets locale via locale.setlocale(locale.LC_ALL, '') which appears to be the accepted method of setting locale in python.

Gary

Thomas Keffer

unread,
Jan 22, 2017, 9:50:08 AM1/22/17
to weewx-user
On Sun, Jan 22, 2017 at 1:45 AM, Darryn Capes-Davis <wea...@carlingfordweather.sydney> wrote:

>>> import locale
>>> locale.setlocale(locale.LC_ALL,'')
'en_AU.UTF-8'
>>> import datetime
>>> datetime.datetime.now().strftime("%x %X")
'22/01/17 20:35:56'

I note that weewx code for 3.7 has the engine run the setlocale() statement. (Tom, was this to fix an issue like this or?... I note that the commit says to just report the locale but it does more than that).


​Yes. 

This was actually added three years ago, well before the "report" commit, in V2.6 (8-Feb-2014).​

-tk

John Rye

unread,
Jan 26, 2017, 6:38:15 AM1/26/17
to weewx-user


On Saturday, 21 January 2017 22:24:08 UTC+13, John Rye wrote:
Hi All,

Replying to self - Bad form :-)

After suffering from a severe storm and a series of very quick power interruptions which KILLED the computer running weewx I have finally got things running again.

I have realised my problem was more than likely that I followed the instructions on Nico's github pages and installed by manually copying the code into place. To be honest I really no idea that was the reason either.

At this point my default installation is at: http://newall-wx.gen.nz.

On a separate machine on my network I've installed and configured weewx and and then used wee_extension to install the Niculskin. I have now got it working reliably using the simulator engine after a great many hours of tweeking along the lines indicated by Gary.

So is it now simply a matter of copying the entire weewx codebase from the simulator setup to the live system and running wee_config --reconfigure?

There are a couple of weird displays on the test setup that I haven't been able to resolve but I'll address that in another thread.

Cheers (I think)

John in NZ

Reply all
Reply to author
Forward
0 new messages