hourly range
-
I would like to show the next 3 hours from the current time. Is that possible?
-
Hi, @expient.
I updated the plugin to allow this. Please update to version 1.4.5
Shortcode example (note the addition of “max-3” class, which is only applicable if you use the CSS I provide below):
[tk_event_weather class="max-3" location="The White House" start_time="now" end_time="+3 hours"]
At 12:06pm, this shortcode will display 12pm, 1pm, 2pm, 3pm, and 4pm — because the shortcode always “bookends” the hours — so it rounds 12:06pm down to 12:00 and rounds 3:06pm up to 4:00pm. So if you’d like only 12pm, 1pm, and 2pm to be displayed, you could add this CSS:
.tk-event-weather__wrapper.max-3 .template-hourly_horizontal__item:nth-of-type(1n+4) { display: none; }
I hope this works great for you!
If it does, I’d appreciate a 5-star review!
Please let me know how this goes for you.
Hi, WOW THANKS!
It’s working (almost, is it supposed to work this way?).
It is currently 10:42 and with this short code I’m getting back 5 hrs. 10AM – 2PM.[tk_event_weather class="max-3" location="The White House" start_time="now" end_time="+3 hours"]
10:42 + 3 hours = 1:42pm
Then you “bookend” them and 10:42 rounds down to 10am and 1:42pm rounds up to 2pm.
If you were to have a sunrise or sunset in there too, you’d have a 6th item in the hourly list (unless you use the shortcode argument to disable this).The weather API can only display hourly weather for the top of each hour, which is why if someone wants to display the weather for 10:20am or 10:50am, it just displays both 10am and 11am.
So, yes, it’s working as expected, and feel free to share your feedback.
Thanks. I’m a little confused. Is there a way to always show 3 items?
For example:
9:55AM
9am, 10am, 11am10:05AM
10am, 11am, 12pm10:55AM
10am, 11am, 12pmIf I experiment and see the result I want, will that fluctuate by 1 item depending on the current time?
Never mind, I think I have it now. As long as I use the css to cut off the extras, it will always be 3 max. Works great!
Thanks.You might also experiment with just “+1 hour” or “+2 hours”:
+1:
9:59am: 9, 10, 11+2:
9:59am: 9, 10, 11, 12trying to find the short code argument to disable sunrise/sunset
sunrise_sunset_off="true"
or it’s possible to disable it by default via the plugin settings page.Interesting… may have found a bug…
at 10:45pm
I have 2 items
10pm
11pmat 11pm
I have 1 item
11pmI manually changed the clock on my computer to 12am now I have 3 items again.
Is there a way to span days?
Your computer clock wouldn’t affect anything at all with the shortcode’s output, but your server’s “now” timestamp would if that’s how you’re using the shortcode.
If you’re exactly at the top of the hour, then there’s no rounding up or down, which is why the “+1 hour” might result in only 2 total hours displayed instead of 3.
Examples:
A) at 9:59am + 1 hour, it would display 9am, 10am, and 11am.
B) at 10:00am + 1 hour, it would display only 10am and 11 am.If you’re experiencing something different (i.e. a bug), please share your full shortcode and its expected output (and what’s unexpected about it).
Regarding multiple days, please reference “Example F” from the “What are some shortcode examples?” FAQ.
Hi, I hope I’m not being a pain in the butt.
I’m on a local dev machine, so I was able to affect the plugin by changing my computer clock.
I was thinking of trying something like Example F, but I’m using a start_time of “now”. Here’s my shortcode.
[tk_event_weather lat_long ="41.787917,-72.889642" start_time="now" end_time="+3 hours"]
I’m trying to show a rolling 5 hour forecast. I can’t figure out how to sequence 2 short codes together based on “now”.
In terms of a “bug”, I was wondering why a start_time of “now” (11:05pm) doesn’t extend into the next day.
at 11:05am I see
11am
12pm
1pm
2pm
3pmat 11:05pm I see
11pmI would like to see
11pm
12am
1am
2am
3amThanks for the awesome plugin!
You can reference https://secure.php.net/manual/en/datetime.formats.relative.php
Note that the PHP relative date formats like “now” are determined by your server, not your WordPress timezone or the weather API’s location’s timezone… thus, I unfortunately wasn’t able to figure out a way to pull this off reliably.
I think this has therefore pushed me over the edge to implement multi-day functionality (without custom CSS required). Unfortunately, this would need to take some time (both in strategy and actual coding) and I’m busy right now.
If you have an urgent need, I could prioritize this if you’d like to sponsor its development. Otherwise, it might be a while.
Thanks. For my particular situation it will be okay if it winds down at midnight.
Thanks again for all your help!
Glad to help! Feel free to share your implementation once it’s all setup.
Or if you have other feature request ideas or need an add-on to integrate with a particular calendar solution, let me know.
Have a great day!
- The topic ‘hourly range’ is closed to new replies.