Thread Tools Display Modes
09-12-09, 05:27 PM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Changing AM/PM to lower case

I want to change the %p output to display lowercase instead of uppercase. Any way to do this?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-12-09, 06:25 PM   #2
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
I don't think there's any "option" like %p to use but you could use string.lower()
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.
  Reply With Quote
09-12-09, 06:42 PM   #3
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Hmm how would i go about that? the other way i see to do it is to write a script that basicly reads....

If %p = AM then SetText:am

or something along those lines that obviously isnt a functioning piece of code but...

was hoping their was an easier way
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-12-09, 07:44 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
http://wowprogramming.com/docs/api/strlower
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-13-09, 08:25 AM   #5
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Hmm i cant seem to get anything to work....

i tried this bit of code changing the strlower part up a few dif ways.
Code:
local previousMinute, timer = -1, -1
Clock:SetScript('OnUpdate', function(self, elapsed)
	PM = strlower(pm);
	AM = strlower(am);
	timer = timer - elapsed
	if timer > 0 then return end
	timer = 5
	server_hour, server_minute = GetGameTime()
	if server_minute == previousMinute then return end
	previousMinute = server_minute
	Time:SetText(("%d:%s"):format(tonumber(date("%I")), date("%M %p")))
	if self.tooltip then
		OnEnter(self)
	
	end
i also tried > = string.lower("pm")

among other things, including changing the position of that line in the script....
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-13-09, 08:29 AM   #6
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Code:
Time:SetText(date("%I:%M%p"):lower())
You can put your whole format() into the date() function, since it works like format(). And then you lower() the whole resulting string before passing it to :SetText()
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
09-13-09, 08:35 AM   #7
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
according to the wow api lower() lowers the frame level. not the capitalization..... gonna try it anyhow.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-13-09, 08:39 AM   #8
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
This looks like it should work but its not so far.... i think this is how you were saying to do it Cargor?

Code:
Time:SetText(("%d:%s"):format(tonumber(date("%I")), :strlower((date("%M %p"))))
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-13-09, 08:43 AM   #9
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Does my code not work?

myString:lower() is basically the short form for string.lower(myString) or strlower(myString).

Without the ":" before strlower, your code should work.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
09-13-09, 09:04 AM   #10
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
I think you can just do this, basically the same as already posted...:

Code:
Time:SetText((date("%I:%M %p")):lower())
  Reply With Quote
09-13-09, 09:04 AM   #11
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
took the : out and it worked perfect. Thanks

final working code is

Code:
Time:SetText(("%d:%s"):format(tonumber(date("%I")),strlower((date("%M%p")))))
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-13-09, 11:31 AM   #12
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Cargor View Post
Does my code not work?

myString:lower() is basically the short form for string.lower(myString) or strlower(myString).

Without the ":" before strlower, your code should work.
Where did you find :lower()? WoW's shortcut for string.lower is strlower, and I haven't seen anything about :lower(). It's not on the fontstring list/page at wowprogramming either. Is it provided by a library?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-13-09, 12:09 PM   #13
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Frame:Lower()
Reduces the frame's frame level, layering it behind other frames in its strata
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
09-13-09, 12:20 PM   #14
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
I haven't checked wowwiki, but I've used it before, and I just logged in to test:
Code:
("HI"):lower()
works fine and results in "hi" with no addons active.
  Reply With Quote
09-13-09, 12:44 PM   #15
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Originally Posted by Seerah View Post
Where did you find :lower()? WoW's shortcut for string.lower is strlower, and I haven't seen anything about :lower(). It's not on the fontstring list/page at wowprogramming either. Is it provided by a library?
All strings are derived from the "string"-table, so instead of string.lower(myString) you can write myString:lower(), because they inherit the functions of "string". Same goes for gsub(), match() and so on.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
09-13-09, 01:10 PM   #16
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
and you can do funky stuff like this
lua Code:
  1. string.print = print
  2.  
  3. local x = "FOOOO"
  4. x:print()

:P

In essence all strings have a metatable of {__index = string}, and infact after checking it in the lua web demo you can prove it with
Code:
print(getmetatable("BLAH").__index == string)
WoW is slightly different as strings metatables don't seem to have an __index field and instead reference string directly
Code:
print(getmetatable("BLAH") == string)

Last edited by Slakah : 09-13-09 at 01:26 PM.
  Reply With Quote
09-13-09, 03:21 PM   #17
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Thanks for the answers. Makes sense now.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Changing AM/PM to lower case


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off