Created
April 30, 2021 15:03
-
-
Save cgi-caesar/86c99535e13466c2dc19ee07ea98c7da to your computer and use it in GitHub Desktop.
aMember (site.js): change absolute dates to relative in Active Subscription widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function(){ | |
jQuery('.am-list-subscriptions-date_expires_date, .am-list-subscriptions-date_rebill_date, .am-list-subscriptions-date_future_date').each(function(){ | |
if (jQuery(this).data('date') == '2037-12-31') return; | |
const today = new Date().toISOString().slice(0, 10) | |
const diffInDays = 1 + (new Date(jQuery(this).data('date')) - new Date(today)) / (1000 * 60 * 60 * 24); | |
jQuery(this).attr('title', jQuery(this).html()); | |
jQuery(this).html(`in ${diffInDays} ${diffInDays == 1 ? 'day' : 'days'}`); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment