Author Topic: OK, here's an easy one!  (Read 3172 times)

xairbusdriver

  • Storm
  • *****
  • Posts: 3127
    • EW7115 (E7115)
    • KTNGERMA20
    • Mid-South Weather
  • Station Details: Davis VP2 wireless + remote Anemometer/2014 Mac min - 10.15.7/WC 3.0.5
OK, here's an easy one!
« on: May 28, 2016, 04:50:37 AM »
I was adding a wee bit of php to convert the "PM" and "AM" to "pm" and "am" on my home page. All was fine until I got to the CU$ tag. [banghead] I can strip the last two characters from the string and convert them to lower case...

OTOH, none of this 'tweaking' would be needed if our beloved Dev would simply change the prefs a bit. And while he's at it, how about a lower case "mph", also:
As you can see, I've already done the hard part...  [rolleyes2]
THERE ARE TWO TYPES OF COUNTRIES
Those that use metric = #1 Measurement system
And the United States = The Banana system


elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 6494
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
How hard is it to change case in PHP? (Re: OK, here's an easy one!)
« Reply #1 on: May 28, 2016, 11:00:48 PM »
Dear X-Air and WeatherCat scripters,

I was adding a wee bit of php to convert the "PM" and "AM" to "pm" and "am" on my home page. All was fine until I got to the CU$ tag. [banghead] I can strip the last two characters from the string and convert them to lower case...

Okay I see your point, but what appears to be a small change to WeatherCat is I suspect more time consuming than it looks.  Changing the OS X user-interface appears to be more tedious than it should be and every little change like this is time that Stu doesn't spend on more substantial upgrades.

Is it really all that difficult to change the case of a string in PHP?  I've never had a chance to learn PHP, but I've used Perl and that is the sort of thing which you could on a few lines of code.  Is it much harder in PHP?

Curious minds want to know . . . . .

Edouard

xairbusdriver

  • Storm
  • *****
  • Posts: 3127
    • EW7115 (E7115)
    • KTNGERMA20
    • Mid-South Weather
  • Station Details: Davis VP2 wireless + remote Anemometer/2014 Mac min - 10.15.7/WC 3.0.5
Re: OK, here's an easy one!
« Reply #2 on: May 29, 2016, 05:17:51 AM »
Uhmn... Please lighten up a bit Edouard. ;) Of course it's not as simple as changing the list items in the Prefs dialog.  [rolleyes2] I know that, Stu knows that, and I would have thought you would have known that. My bad for making it sound trivial. But I thnk we can trust his priorities and not worry about anything being delayed by my extremely minor and personal wants.

The PHP 'fix' is trivial. I simply placed the WC STATS tag in a "strtolower(string)" PHP built in function call. I suspect even AppleScript has the same built in function. WC automagically replaces the tags with the help:mm PM or AM text and when the edited file gets uploaded, the PHP function does its magic and the "echo" places the changed string in the HTML the browser sees/displays. Not even necessary to make a request to include any PHP files/scripts.

It could be done in the templates most people use, if that template wasn't already doing this conversion it its own set up. Since I don't use any site-wide, prebuilt template, I just do it where I want it.

The "problem" is that it's only this simple when the "am/PM" is a separate WC tag. The "CU$" tag builds those last two characters into the Date/Time output, not as a separate item. Using just the strtolower on that string will also make the first letter of the month into a lower case character (may 30, 2016 4:56 pm). OTOH, it's always the last two characters of the string that 'need' the case change. So all that's required, in that case, is to simply change the case of the last two characters. A bit more work, but the built in functions are there.

Probably 99.8% of WC users don't care about this detail. There may even be some grammatical rule that claims these letters should be CAPITALS. And 50% of the other folks don't even notice! Of the .1%, there may only be half who would make use of this change! So that leaves .05% of WC users who just might actually use this capability. I can't see Stu spending much time on it... Relax!

The easiest thing would be to write a page with basically nothing but all the WC tags I use and let WC upload just that one file. Then PHP can manipulate the text and create every variable used in the site. That similar, I think, to what at least one template does now.

Frankly, I am hoping that my request at least brought a smile for the he Dev!
THERE ARE TWO TYPES OF COUNTRIES
Those that use metric = #1 Measurement system
And the United States = The Banana system


WCDev

  • WeatherCat Developer
  • Administrator
  • Storm
  • *****
  • Posts: 2911
    • CW9739
    • ISCOTLAN25
    • Trixology
  • Station Details: Main Station: Vantage Pro-2, 24hr fars, solar, soil/leaf station, extra temp stations, no U.V. WeatherLink IP.
Re: OK, here's an easy one!
« Reply #3 on: May 29, 2016, 10:21:03 AM »
>OK, here's an easy one
No it isn't :)

I was adding a wee bit of php to convert the "PM" and "AM" to "pm" and "am" on my home page. All was fine until I got to the CU$ tag. [banghead] I can strip the last two characters from the string and convert them to lower case...

The 12 hour clock ante and post meridiem indicators are subject to regionalisation/localisation throughout WeatherCat.

So in the UK we would have 'am', but in Germany the output of the CU$ tag would look something like:
Time of data: 29 Mai 2016 10:05 vorm.

The take away is to be careful of formatting when processing tags - they are localised. There are tags available to cope with this for certain situations when machine parsing - for example ISO8601DATES$ (all date/times out of STAT$ tags) and DOTSEPERATORS$ (affects all numbers in STAT$ output).

xairbusdriver

  • Storm
  • *****
  • Posts: 3127
    • EW7115 (E7115)
    • KTNGERMA20
    • Mid-South Weather
  • Station Details: Davis VP2 wireless + remote Anemometer/2014 Mac min - 10.15.7/WC 3.0.5
Re: OK, here's an easy one!
« Reply #4 on: May 29, 2016, 02:21:39 PM »
Quote
No it isn't :)
As I replied above your post, "Of course it's not as simple as changing the list items in the Prefs dialog. [rolleyes2] I know that, Stu knows that..." Since I have my own site files, I can handle it, while depending on you to make it as universal and standardized as possible.
Quote
As you can see, I've already done the hard part...   [rolleyes2]
I guess my subtle "humor/humour" was not as effective as I intended.Sorry to have cluttered up the forums with my trivial "complaint". [tup] At least I got a smiley out of you! Please just keep up the great work! [cheer]

And the Admin are encouraged to delete this whole thread if they wish. [computer] The only significant info comes from the details the Dev goes to when he created the app.
THERE ARE TWO TYPES OF COUNTRIES
Those that use metric = #1 Measurement system
And the United States = The Banana system


elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 6494
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
The wink emoticon IS useful! (Re: OK, here's an easy one!)
« Reply #5 on: May 29, 2016, 11:44:50 PM »
Dear X-Air, Stu, and WeatherCat . . . . way too busy with life types,

Uhmn... Please lighten up a bit Edouard. ;)

I've been caught in the predicament you describe and that's why when I make a joke - I go to great lengths to make clear that it is obviously a joke.

 [wink] . . . That's a joke son, gag that is! . . . .  [biggrin]

I like to kid around as much as anybody, but nobody has enough time to respond to these forum posts.  So if you want to be 100% sure everybody will take it the right way - take the time to mark the text as a joke so everyone gets it the first time.

Cheers, Edouard  [cheers1]

xairbusdriver

  • Storm
  • *****
  • Posts: 3127
    • EW7115 (E7115)
    • KTNGERMA20
    • Mid-South Weather
  • Station Details: Davis VP2 wireless + remote Anemometer/2014 Mac min - 10.15.7/WC 3.0.5
Re: OK, here's an easy one!
« Reply #6 on: May 30, 2016, 01:27:22 AM »
What? You mean there are viewers here that don't read every word I type?! I'm sure I remember reading that registering here meant one absolutely, positive had to read every new post, every day! That's why it took me so long to make my first post! When I registered, all 49,301 posts were new! [wink]

As for marking the post as humor/joke/nonsense, there are message icons that can help.

My post was not meant as a joke, anyway. It is a preference I'd like to see, but it is up to the dev and it will never see the light of day. Many of our 'like-to-have' suggestions may be impossible to implement or not of value to enough people. But that's the dev's choice and replies to our posts can help inform him.

I appreciated his kind and detailed reasons for not providing he with my entirely selfish suggestion. I know of some who would have, at best, ignored me, and at worst, abused me verbally. I think Stu is not only a highly skilled coder, but a gentleman in many other ways. I also think the vast majority here think of him similarly. ;)
THERE ARE TWO TYPES OF COUNTRIES
Those that use metric = #1 Measurement system
And the United States = The Banana system


WCDev

  • WeatherCat Developer
  • Administrator
  • Storm
  • *****
  • Posts: 2911
    • CW9739
    • ISCOTLAN25
    • Trixology
  • Station Details: Main Station: Vantage Pro-2, 24hr fars, solar, soil/leaf station, extra temp stations, no U.V. WeatherLink IP.
Re: OK, here's an easy one!
« Reply #7 on: May 30, 2016, 01:35:15 PM »
It's all good - anywhere I get to plug tags like DOTSEPERATORS$ is always useful :)