How to caculate a countdown to the next high and low tide.
First, there is a nice plugin called Tides Today UK and Ireland tide times that allows tidal charts to be displayed using a Sidebar Widget or a shortcode. For example:
[tide_times days=1 title="Tide times for Leith" location="leith"]These are today's tides for Leith[/tide_times]
That outputs a tidy forecast like so:
Tide times for Leith
These are today’s tides for Leith
The shortcode references the authors own web-service api that returns a JSON encoded dataset. Here is the dataset for Leith. However, the plugin author clearly (if not threateningly) states:
You may not use the data provided by the API for anything other than displaying tide information on your website by the
means provided by this plugin.
…Failure to comply with any of the conditions outlined here or as outlined in the Tides Today Terms and conditions will result in legal action being taken.
In the words of Al Swearengen:
Not a tone to get a deal done.
Even though the datasource provide is from the UK Hydrographic Office:
All data is provided by the UK Hydrographic Office and is provided under license. Crown Copyright 2016.
So we might need to find our own, tax-funded, public, non-threatening api to get our tidal info from, for example:
The NOAA api looks quite promising… but it’s only for North America. So we move on to Worworldtides api which provides 1000 free calls per month. So far that is a winner. Now let’s take a look at The National Tidal and Sea Level Facility. It seems it only serves the UK and Ireland. Here is Leith.
This is an example of how a limited time offer would work in conjunction with content in a collapse-o-matic expand element.
This demo uses T(-) Countdown Control with a cookie that tracks when the offer expires for each unique visitor. Once the countdown reaches zero, T(-) Countdown Events will remove any special offer items.
For this demo, we’ll set the special timer for just two minutes. The offer will then be removed for 24 hours, and then after the 24 hours are past, the offer will reset.
this is where the details of the special are presented
This is a test of the new T(-) Opening Hours add-on plugin for T(-) Countdown Control.
It will allow a countdown schedule to be defined by referencing a weekly opening schedule.
Normally a countdown groups the units of time (weeks, days, hours, minutes and seconds) into a single countdown unit. But what if you wanted to break out these units and have them displayed on different parts of the page?
Step One. We will need to add a new attribute that tells the countdown NOT to display any of the digits. This way all the countdown scripts and details are still loaded, but the countdown is not displayed. Something like:
[tminus cid="123" hidden="true" style="cloud-city"/]
Step Two. A new shortcode will need to be created for displaying the time unit. We will need to know the countdown id (cid) the time unit to be displayed, and the style to be used, if other than the default style set up on the plugin settings. If a custom style is used it must be defined in both the countdown and the units like so:
[[tminus_digit cid="123" unit="hours" style="cloud-city"/]]
The final set will be to modify the countdown script to locate the time units, even if they are not wrapped in a countdown dashboard.
Let’s get started.
Here is a hidden countdown:
Now we add all the digits, starting with weeks:
[tminus_digit cid=”281″ id=”explode” unit=”weeks” style=”cloud-city” omitweeks=”false”/]
[tminus_digit cid=”281″ id=”explode” unit=”days” style=”cloud-city”/]
[tminus_digit cid=”281″ id=”explode” unit=”hours” style=”cloud-city”/]
[tminus_digit cid=”281″ id=”explode” unit=”minutes” style=”cloud-city”/]
[tminus_digit cid=”281″ id=”explode” unit=”seconds” style=”cloud-city”/]
Using the new [this year] and [this_easter] shortcodes introduced with T(-) Countdown version 1.8.0, it’s easy to calculate holidays such as labor day like so:
Launch Strtotime: september [this_year] first monday
As of version 1.8.2, using these shortcodes will automatically recalculate for next year’s date after the holiday has past. Holidays should be set as recurring ‘Yearly’ and they will automatically be rescheduled for next year.
Other Holidays can be calculated in the same manner:
- New Years: first day of january [this_year]
- Martin Luther King, Jr. Day: january [this_year] third monday
- President’s Day: february [this_year] third monday
- Easter: [this_easter]
- Ascension Day: [this_easter] + 40 days
- Pentecost: [this_easter] + 50 days
- Memorial Day: last monday of may
- Independence Day: july 4 [this_year]
- Labor Day: september [this_year] first monday
- Columbus Day: october [this_year] second monday
- Veteran’s Day: november 11 [this_year]
- Thanksgiving Day: november [this_year] fourth thursday
- Christmas Day: december 25 [this_year]
Eight Days before Thanksgiving
november [this_year] fourth thursday + 14 hours 30 minutes – 8 days
Test of a faster redirect when a countdown is already expired.
T(-) Countdown Control already has the ability to store a visitors calculated launch time to a cookie. As of version 1.7.7 we have added integration of a new add-on plugin T(-) Countdown Tracking. This new premium plugin adds the ability to save the visitors IP address in the database. More details to follow.
Test using Schedule:
Test using basic shortcode:
[tminus t="+2 minutes" id="test_counter" track_id="2571" /]
This is a test of the cloud-city style for T(-) Countdown to adjust the spacing issue on lower viewports.