Tidal Chart for Leith

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

Location 'leith' was not found


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.

https://tides.today/about/

So we might need to find our own, tax-funded, public, non-threatening api to get our tidal info from, for example:
https://data.gov.uk/publisher/united-kingdom-hydrographic-office
https://www.tidetimes.org.uk/leith-tide-times
even better:
RSS: https://www.tidetimes.org.uk/leith-tide-times.rss
Twitter: https://twitter.com/LeithTideTimes
http://www.ntslf.org/
https://tidesandcurrents.noaa.gov/api/
https://www.worldtides.info/
https://www.wunderground.com/

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.

Leith
http://www.ukho.gov.uk/easytide/EasyTide/ShowPrediction.aspx?PortID=0225&PredictionLength=1

Holy Island
http://www.ukho.gov.uk/easytide/EasyTide/ShowPrediction.aspx?PortID=0208&PredictionLength=1

Limited Time Offer Demo

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.

Details
this is where the details of the special are presented

T(-) Countdown Control – Separating the Time Units

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”/]

Days:
[tminus_digit cid=”281″ id=”explode” unit=”days” style=”cloud-city”/]

Hours:
[tminus_digit cid=”281″ id=”explode” unit=”hours” style=”cloud-city”/]

Minutes:
[tminus_digit cid=”281″ id=”explode” unit=”minutes” style=”cloud-city”/]

Seconds:
[tminus_digit cid=”281″ id=”explode” unit=”seconds” style=”cloud-city”/]

T(-) Countdown Control – Calculating Labor Day & Other Holidays

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]

Tests

Ascension Day

Eight Days before Thanksgiving

november [this_year] fourth thursday + 14 hours 30 minutes – 8 days

T(-) Countdown Control IP Address Tracking

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:

[tminus cid="2022"/]

Test using basic shortcode:

[tminus t="+2 minutes" id="test_counter" track_id="2571" /]
weeks
0
0
days
0
0
hours
0
0
minutes
0
2
seconds
0
0

No Tracking:

days
0
0
hours
0
0
minutes
0
2
seconds
0
0