[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
https://bbs.xwidget.com/

Day and Night images am/pm
https://bbs.xwidget.com/viewtopic.php?f=8&t=3710
Page 1 of 1

Author:  Jimking [ October 28th, 2013, 11:20 am ]
Post subject:  Day and Night images am/pm



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

Author:  Jimking [ October 28th, 2013, 3:32 pm ]
Post subject:  Re: Day and Night images am/pm

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".

Author:  Jimking [ October 28th, 2013, 4:25 pm ]
Post subject:  Re: Day and Night images am/pm


Author:  meme [ October 28th, 2013, 4:35 pm ]
Post subject:  Re: Day and Night images am/pm

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"

}

Author:  Jimking [ October 28th, 2013, 4:53 pm ]
Post subject:  Re: Day and Night images am/pm

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..! ;)

Author:  meme [ October 28th, 2013, 5:32 pm ]
Post subject:  Re: Day and Night images am/pm


Author:  Jimking [ October 28th, 2013, 5:50 pm ]
Post subject:  Re: Day and Night images am/pm

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 8465 times ]

Author:  meme [ October 28th, 2013, 6:44 pm ]
Post subject:  Re: Day and Night images am/pm

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....

Author:  Jimking [ October 28th, 2013, 7:14 pm ]
Post subject:  Re: Day and Night images am/pm

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 8462 times ]
c.png
c.png [ 205.57 KiB | Viewed 8462 times ]

Author:  meme [ October 28th, 2013, 10:18 pm ]
Post subject:  Re: Day and Night images am/pm

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"

}

Author:  Jimking [ October 29th, 2013, 4:21 am ]
Post subject:  Re: Day and Night images am/pm

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 258 times

Author:  digigamer [ October 29th, 2013, 6:29 am ]
Post subject:  Re: Day and Night images am/pm


Author:  Jimking [ October 29th, 2013, 6:52 am ]
Post subject:  Re: Day and Night images am/pm

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.

Author:  Jimking [ October 29th, 2013, 7:37 am ]
Post subject:  Re: Day and Night images am/pm


Author:  qiancang [ October 29th, 2013, 7:56 am ]
Post subject:  Re: Day and Night images am/pm

it must be ok now

Attachments:
halloween_fancy_clock_ok.xwp [790.75 KiB]
Downloaded 247 times

Author:  Jimking [ October 29th, 2013, 8:07 am ]
Post subject:  Re: Day and Night images am/pm


Author:  digigamer [ October 29th, 2013, 10:18 pm ]
Post subject:  Re: Day and Night images am/pm

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.

Author:  meme [ October 29th, 2013, 11:27 pm ]
Post subject:  Re: Day and Night images am/pm

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.

Author:  Jimking [ October 30th, 2013, 3:49 am ]
Post subject:  Re: Day and Night images am/pm


Author:  Oletik [ December 13th, 2013, 11:49 am ]
Post subject:  Re: Day and Night images am/pm


Author:  Jimking [ December 13th, 2013, 12:49 pm ]
Post subject:  Re: Day and Night images am/pm


Author:  digigamer [ December 13th, 2013, 10:40 pm ]
Post subject:  Re: Day and Night images am/pm


Author:  meme [ December 14th, 2013, 1:39 am ]
Post subject:  Re: Day and Night images am/pm

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;

Author:  Oletik [ December 15th, 2013, 12:26 pm ]
Post subject:  Re: Day and Night images am/pm

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

Author:  meme [ December 15th, 2013, 10:27 pm ]
Post subject:  Re: Day and Night images am/pm

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;
}
}

Author:  Oletik [ December 16th, 2013, 11:57 am ]
Post subject:  Re: Day and Night images am/pm

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.

Author:  meme [ December 16th, 2013, 12:11 pm ]
Post subject:  Re: Day and Night images am/pm


Author:  qiancang [ December 16th, 2013, 7:02 pm ]
Post subject:  Re: Day and Night images am/pm

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';
....

Author:  Oletik [ December 17th, 2013, 12:24 pm ]
Post subject:  Re: Day and Night images am/pm

Thank you, qiancang!
My quick test showed that it works well!

Author:  meme [ December 18th, 2013, 9:16 pm ]
Post subject:  Re: Day and Night images am/pm

Thank you, qiancang! good to know !

Author:  Oletik [ December 19th, 2013, 9:56 am ]
Post subject:  Re: Day and Night images am/pm

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.

Author:  qiancang [ December 19th, 2013, 9:42 pm ]
Post subject:  Re: Day and Night images am/pm


Author:  Oletik [ December 20th, 2013, 7:28 am ]
Post subject:  Re: Day and Night images am/pm

Thank you very much!

Author:  Oletik [ December 21st, 2013, 12:13 pm ]
Post subject:  Re: Day and Night images am/pm

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?

Author:  meme [ December 21st, 2013, 2:31 pm ]
Post subject:  Re: Day and Night images am/pm


Author:  Oletik [ December 22nd, 2013, 7:23 am ]
Post subject:  Re: Day and Night images am/pm

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.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/