XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently May 7th, 2025, 11:59 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: March 24th, 2014, 1:15 am 
Offline

Joined: March 18th, 2014, 1:49 pm
Posts: 13
I noticed that the sun and moon rises and sets are in 24 hr format.
how can you set those times to be in 12 hr?


Top
 Profile  
 
PostPosted: March 24th, 2014, 1:43 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
I wanted to but I'm afraid that we have to wait for the next version of XWidget. I hope that the Dev will add new tags for this..
Like the 12h for the weather's update time..

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: March 27th, 2014, 3:35 pm 
Offline

Joined: October 26th, 2013, 8:17 am
Posts: 362
ELY_M wrote:
I noticed that the sun and moon rises and sets are in 24 hr format.
how can you set those times to be in 12 hr?

if you familiar with scripting you can do this with a little scripting:
just you need to split hh:mm by ":" to get the hour from it and change the hour to 12hour and recreate the hh:mm format:

example:
//need to create text1 Object
//need to have accweathercore1 in widget
//don't forget to add [datetimecore1OnUpdate] in the [OnUpdate] Section of datetimecore1 in designer

Code:
function datetimecore1OnUpdate(Sender)
{
  tmp1=accweathercore1.get("%sunSet").split(":")
  if(tmp1[0]>12)
  {
     tmp1[0]=tmp1[0]-12
     text1.Text=tmp1[0]+":"+tmp1[1]+" PM"
  }
  else if(tmp1[0]==0)
  {
     text1.Text=12+":"+tmp1[1]+" AM"
  }
  else if(tmp1[0]==12)
  {
     text1.Text=12+":"+tmp1[1]+" PM"
  }
  else if(tmp1[0]<12)
  {
     text1.Text=tmp1[0]+":"+tmp1[1]+" AM"
  }
}


Top
 Profile  
 
PostPosted: March 27th, 2014, 4:09 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Good hamid! ;)
I continue to believe though that if Tony add a tag for this on the next version, will be more simple for all. :)

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: April 3rd, 2014, 3:52 pm 
Offline

Joined: March 18th, 2014, 1:49 pm
Posts: 13
I did scripting. I had to modify to strip the 0 from the sunrise

Code:
function datetimecore1OnUpdate(Sender)
{
//sunrise
  tmp1=accweathercore1.get("%sunRise").split(":")
  if(tmp1[0]>12)
  {
     tmp1[0]=tmp1[0]-12
     sunrise.Text="Sunrise: "+tmp1[0]+":"+tmp1[1]+" PM"
  }
  else if(tmp1[0]==0)
  {
     sunrise.Text="Sunrise: "+12+":"+tmp1[1]+" AM"
  }
  else if(tmp1[0]==12)
  {
     sunrise.Text="Sunrise: "+12+":"+tmp1[1]+" PM"
  }
  else if(tmp1[0]<12)
  {
     if (amhour=tmp1[0].split("0"))
     sunrise.Text="Sunrise: "+amhour[1]+":"+tmp1[1]+" AM"
     else
     sunrise.Text="Sunrise: "+tmp1[0]+":"+tmp1[1]+" AM"
  }
//sunset
  tmp1=accweathercore1.get("%sunSet").split(":")
  if(tmp1[0]>12)
  {
     tmp1[0]=tmp1[0]-12
     sunset.Text="Sunset: "+tmp1[0]+":"+tmp1[1]+" PM"
  }
  else if(tmp1[0]==0)
  {
     sunset.Text="Sunset: "+12+":"+tmp1[1]+" AM"
  }
  else if(tmp1[0]==12)
  {
     sunset.Text="Sunset: "+12+":"+tmp1[1]+" PM"
  }
  else if(tmp1[0]<12)
  {
     sunset.Text="Sunset: "+tmp1[0]+":"+tmp1[1]+" AM"
  }



}


Top
 Profile  
 
PostPosted: April 3rd, 2014, 4:25 pm 
Offline

Joined: October 26th, 2013, 8:17 am
Posts: 362
edit:
i didn't noticed that you have done with removing 0 from it,
so have this one as another way;
==================

and some tips:
i forgot to tell, you can also use [accweathercore] for update instead of [datetimecore];
(to lower the resource usage)

==================
just added this line to previous code, this will convert the string to integer:
Code:
tmp1[0]=parseInt(tmp1[0],10)


here's the full code:
Code:
function datetimecore1OnUpdate(Sender)
{
//sunrise
  tmp1=accweathercore1.get("%sunRise").split(":")
  tmp1[0]= parseInt(tmp1[0],10)
  if(tmp1[0]>12)
  {
     tmp1[0]=tmp1[0]-12
     sunrise.Text="Sunrise: "+tmp1[0]+":"+tmp1[1]+" PM"
  }
  else if(tmp1[0]==0)
  {
     sunrise.Text="Sunrise: "+12+":"+tmp1[1]+" AM"
  }
  else if(tmp1[0]==12)
  {
     sunrise.Text="Sunrise: "+12+":"+tmp1[1]+" PM"
  }
  else if(tmp1[0]<12)
  {
     sunrise.Text="Sunrise: "+tmp1[0]+":"+tmp1[1]+" AM"
  }
//sunset
  tmp1=accweathercore1.get("%sunSet").split(":")
  tmp1[0]=parseInt(tmp1[0],10)
  if(tmp1[0]>12)
  {
     tmp1[0]=tmp1[0]-12
     sunset.Text="Sunset: "+tmp1[0]+":"+tmp1[1]+" PM"
  }
  else if(tmp1[0]==0)
  {
     sunset.Text="Sunset: "+12+":"+tmp1[1]+" AM"
  }
  else if(tmp1[0]==12)
  {
     sunset.Text="Sunset: "+12+":"+tmp1[1]+" PM"
  }
  else if(tmp1[0]<12)
  {
     sunset.Text="Sunset: "+tmp1[0]+":"+tmp1[1]+" AM"
  }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 33 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group