[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4668: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4670: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4671: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4672: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
XWidgetSoft Forum • View topic - Day and Night images am/pm

XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently April 18th, 2024, 8:03 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 36 posts ] 
Author Message
PostPosted: October 28th, 2013, 11:20 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887


Attachments:
card_game_clock_v2.xwp [1.12 MiB]
Downloaded 253 times

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/
Top
 Profile  
 
PostPosted: October 28th, 2013, 3:32 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Edit: I used this example
viewtopic.php?f=3&t=2888

but this method works when you have two png files for all day, one for "am" and one for "pm".

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


Top
 Profile  
 
PostPosted: October 28th, 2013, 4:25 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887

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


Top
 Profile  
 
PostPosted: October 28th, 2013, 4:35 pm 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268
Is this OK ?

function datetimecore1OnUpdate(Sender) // only needs to be triggered every minute or hour.
{
var mydate = new Date();
var h = mydate.getHours();

if(h>=0 && h<=5)
image1.src=widgetpath+"1.png"

if(h>=6 && h<=11)
image1.src=widgetpath+"2.png"

if(h>=12 && h<=19)
image1.src=widgetpath+"3.png"

if(h>=20 && h<=23)
image1.src=widgetpath+"4.png"

}


Top
 Profile  
 
PostPosted: October 28th, 2013, 4:53 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
This WORKS meme!!! :D
This works with the 4 am/pm images pasted on the 2 day/night images.

It could be great if can work with 24h too...

I can create four more 4 "empty" images without the am/pm on them..
Also I have the 4 am/pm images separate.. That must be hidden on 24h mode..
Can the script be "modified" so will work on 12h and 24h mode?

If it will be a trouble doing this don't worry meme..! ;)

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


Top
 Profile  
 
PostPosted: October 28th, 2013, 5:32 pm 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268


Top
 Profile  
 
PostPosted: October 28th, 2013, 5:50 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
I mean meme that your previous (working of course) script code is for 12h mode. This means that we have these four images:

But the am/pm are part of the images and didn't change/HIDE on 24h clock. (right click option) From 9:05 am to 21:05 for example


Attachments:
oooo.jpg
oooo.jpg [ 112.06 KiB | Viewed 8449 times ]

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/
Top
 Profile  
 
PostPosted: October 28th, 2013, 6:44 pm 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268
var h = mydate.getHours(); // h is not affected by the setting for 12h and 24h mode it will be a number from 0 to 23 representing the hour.
The "%is12hr" tag can be use to detect which mode is selected and tell the code what to do.
Not sure exactly what you want it to do....


Top
 Profile  
 
PostPosted: October 28th, 2013, 7:14 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Here is what I mean..

I have ready the 4 am/pm ONLY images (separate from the main image) and the 2 backgound images day/night.


Attachments:
1.png
1.png [ 201.99 KiB | Viewed 8446 times ]
c.png
c.png [ 205.57 KiB | Viewed 8446 times ]

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/
Top
 Profile  
 
PostPosted: October 28th, 2013, 10:18 pm 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268
Something like....

function datetimecore1OnUpdate(Sender) // only needs to be triggered every minute or hour.
{
var mydate = new Date();
var h = mydate.getHours(); // a number from 0 to 23 representing the hour
var m = datetimecore1.get("%is12hr"); // returns true if in 12Hr mode, false if in 24Hr mode

if(h>=0 && h<=5 && m=="true") //................................................................modify these lines to get the logic you need
image1.src=widgetpath+"1.png"

if(h>=6 && h<=11 && m=="false") //................................................................modify these lines to get the logic you need
image1.src=widgetpath+"2.png"

if(h>=12 && h<=19) //................................................................modify these lines to get the logic you need
image1.src=widgetpath+"3.png"

if(h>=20 && h<=23) //................................................................modify these lines to get the logic you need
image1.src=widgetpath+"4.png"

}


Top
 Profile  
 
PostPosted: October 29th, 2013, 4:21 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Here is the widget meme to check it.. I tested but seems to not work properly.. Also the am/pm images are not disappear with %24h clock..


Attachments:
halloween_fancy_clock_ok(1).xwp [790.73 KiB]
Downloaded 257 times

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/
Top
 Profile  
 
PostPosted: October 29th, 2013, 6:29 am 
Offline
User avatar

Joined: March 8th, 2013, 10:27 pm
Posts: 353

_________________
Life is a myriad game... Just play it!


Top
 Profile  
 
PostPosted: October 29th, 2013, 6:52 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Thanks DG but are missing some things again:
-The AM/PM can now be hidden. OK
BUT
- The background didn't changed day/night

-The other two am/pm night images are not showing.

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


Top
 Profile  
 
PostPosted: October 29th, 2013, 7:37 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887

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


Top
 Profile  
 
PostPosted: October 29th, 2013, 7:56 am 
Offline
User avatar

Joined: June 10th, 2012, 5:57 am
Posts: 313
it must be ok now


Attachments:
halloween_fancy_clock_ok.xwp [790.75 KiB]
Downloaded 247 times
Top
 Profile  
 
PostPosted: October 29th, 2013, 8:07 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887

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


Top
 Profile  
 
PostPosted: October 29th, 2013, 10:18 pm 
Offline
User avatar

Joined: March 8th, 2013, 10:27 pm
Posts: 353
About the times... Sorry, our sunset occurs at about 17:00 - 18:30, so little bit accustomed to it. I think you should take that into consideration too.

_________________
Life is a myriad game... Just play it!


Top
 Profile  
 
PostPosted: October 29th, 2013, 11:27 pm 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268
How far do you want to go....
Get the sunrise and sunset tags from the accweathercore to control the times things change in your location.


Top
 Profile  
 
PostPosted: October 30th, 2013, 3:49 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887

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


Top
 Profile  
 
PostPosted: December 13th, 2013, 11:49 am 
Offline

Joined: October 30th, 2012, 10:48 am
Posts: 38


Top
 Profile  
 
PostPosted: December 13th, 2013, 12:49 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887

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


Top
 Profile  
 
PostPosted: December 13th, 2013, 10:40 pm 
Offline
User avatar

Joined: March 8th, 2013, 10:27 pm
Posts: 353

_________________
Life is a myriad game... Just play it!


Top
 Profile  
 
PostPosted: December 14th, 2013, 1:39 am 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268
Why would this not work ? add accweathercore to the widget then

function datetimecore1OnUpdate(Sender) //only needs to be triggered every minute or hour.
{

var h = parseInt(datetimecore1.get("%hour")); //number 0 to 23 the hour
var ap = datetimecore1.get("%AMPM");
var is12hr = datetimecore1.get("%is12hr"); //true if 12Hr mode, false if 24Hr mode
var sr = parseInt(accweathercore1.get("%sunRise")); //sunrise hour
var ss = parseInt(accweathercore1.get("%sunSet")); //sunset hour

if(is12hr=="true")
{
ampm_night.Visible = ampm_day.Visible = true;
if(h==12)
{
if(ap=="AM")h=0;
}
else if(ap=="PM") h=h+12;
}
else{ ampm_night.Visible = ampm_day.Visible = false;}

if(h>=sr && h<ss)
{
bg_day.Visible = true;
bg_night.Visible = false;


Top
 Profile  
 
PostPosted: December 15th, 2013, 12:26 pm 
Offline

Joined: October 30th, 2012, 10:48 am
Posts: 38
Sunrise and sunset not only hours, but in minutes (exp: 6:04 ~ 18:58)
How to take a minutes? 18:58 it's almost 19:00, not 18:00


Top
 Profile  
 
PostPosted: December 15th, 2013, 10:27 pm 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268
does this work :?:

function datetimecore1OnUpdate(Sender) // only needs to be triggered every minute or hour.
{

var h = parseInt(datetimecore1.get("%hour")); //number 0 to 23 the hours
var m = parseInt(datetimecore1.get("%minute0")); //number 00 to 59 minutes
var ap = datetimecore1.get("%AMPM");
var is12hr = datetimecore1.get("%is12hr"); //true if 12Hr mode, false if 24Hr mode
var srh = parseInt(accweathercore1.get("%sunRise")); //sunrise hour
var srm = parseInt(accweathercore1.get("%sunRise").slice(-2)); //sunrise minute
var ssh = parseInt(accweathercore1.get("%sunSet")); //sunset hour
var ssm = parseInt(accweathercore1.get("%sunSet").slice(-2)); //sunset minute
var isDaytime;

if(is12hr=="true")
{
ampm_night.Visible = ampm_day.Visible = true;
if(h==12)
{
if(ap=="AM")h=0;
}
else if(ap=="PM") h=h+12;
}
else{ ampm_night.Visible = ampm_day.Visible = false;}

if((h>=srh && m>srm) || (h>=(srh+1))) //sun has risen
isDaytime = 1;

if((h>=ssh && m>ssm) || (h>=(ssh+1))) //sun has set
isDaytime = 0;

if(isDaytime = 1)
{
bg_day.Visible = true;
bg_night.Visible = false;
}
else
{
bg_day.Visible = false;
bg_night.Visible = true;
}
}


Top
 Profile  
 
PostPosted: December 16th, 2013, 11:57 am 
Offline

Joined: October 30th, 2012, 10:48 am
Posts: 38
I don't use 12/24 & AM/PM mode. For myself I wrote:

function datetimecore1OnUpdate(Sender)
{
var hw = parseInt(datetimecore1.get("%hour")); //number 0 to 23 the hour
var mw = parseInt(datetimecore1.get("%minute0"));//number 00 to 59 minutes
var srh = parseInt(accweathercore1.get("%sunRise")); //sunrise hour
var srm = parseInt(accweathercore1.get("%sunRise").slice(-2)); //sunrise minute
var ssh = parseInt(accweathercore1.get("%sunSet")); //sunset hour
var ssm = parseInt(accweathercore1.get("%sunSet").slice(-2)); //sunset minute

if(hw>=srh && mw>=srm)
{
bg_day.Visible = true;
bg_night.Visible = false;
}
if(hw>=ssh && mw>=ssm)
{
bg_day.Visible = false;
bg_night.Visible = true;
}
}

Sorry but there is a bug somewhere. I tested by changing the system time.


Top
 Profile  
 
PostPosted: December 16th, 2013, 12:11 pm 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268


Top
 Profile  
 
PostPosted: December 16th, 2013, 7:02 pm 
Offline
User avatar

Joined: June 10th, 2012, 5:57 am
Posts: 313
function datetimecore1OnUpdate(Sender)
{
var curtime = datetimecore1.get("%time0"); // current time in string format, if you use 12h mode, you have to convert this time string to 24h mode and in '01:43' ,'13:54' format
var risetime = accweathercore1.get("%sunRise"); //sunrise time
var settime = accweathercore1.get("%sunSet"); //sunset time

if(risetime.length==4) risetime=0+risetime // 6:56 -> 06:56, you can do it without judgement since sunrise time always in morning

if(curtime>=risetime && curtime<=settime) //it's ok to compare them in string format directly
{
bg_day.Visible = true;
bg_night.Visible = false;
}
else
{
bg_day.Visible = false;
bg_night.Visible = true;
}
}


this code has potential risk for we may get nothing from accuweathercore in some conditions.

it will be perfect to deal with the following case

var risetime = accweathercore1.get("%sunRise"); //sunrise time
if(risetime=='') risetime ='06:00';
....


Top
 Profile  
 
PostPosted: December 17th, 2013, 12:24 pm 
Offline

Joined: October 30th, 2012, 10:48 am
Posts: 38
Thank you, qiancang!
My quick test showed that it works well!


Top
 Profile  
 
PostPosted: December 18th, 2013, 9:16 pm 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268
Thank you, qiancang! good to know !


Top
 Profile  
 
PostPosted: December 19th, 2013, 9:56 am 
Offline

Joined: October 30th, 2012, 10:48 am
Posts: 38
But why change bg_day to bg_night at sunset occurs at one minute later than the time of sunset?
At sunrise, all is well, minute in minute.


Top
 Profile  
 
PostPosted: December 19th, 2013, 9:42 pm 
Offline
User avatar

Joined: June 10th, 2012, 5:57 am
Posts: 313


Top
 Profile  
 
PostPosted: December 20th, 2013, 7:28 am 
Offline

Joined: October 30th, 2012, 10:48 am
Posts: 38
Thank you very much!


Top
 Profile  
 
PostPosted: December 21st, 2013, 12:13 pm 
Offline

Joined: October 30th, 2012, 10:48 am
Posts: 38
If change the city for the weather, the image (bg_day, bg_night) don't changing because DateTimeCore is set to the first city. It's bad. How to do so that with changing city for the weather the image change too?


Top
 Profile  
 
PostPosted: December 21st, 2013, 2:31 pm 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268


Top
 Profile  
 
PostPosted: December 22nd, 2013, 7:23 am 
Offline

Joined: October 30th, 2012, 10:48 am
Posts: 38
I know how to change Time Zone manually, thank's meme!
But how to do so that with changing city for the weather the image ("bg_day", "bg_night") automatically change to the city for the weather, not my location. For example: in my city now night and weather set for my city - "bg_night". When I change weather for New York, where now a day, "bg_night" must change to "bg_day" automatically.


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

All times are UTC - 8 hours


Who is online

Users browsing this forum: Bing [Bot] and 71 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:  
cron

Powered by phpBB® Forum Software © phpBB Group