“Google Apps Script Moment JS” Kode Jawaban

Google Apps Script Moment JS

function testMoment() {
  eval(UrlFetchApp.fetch('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js').getContentText());
  var date = moment().format("MMM Do YY");
  Logger.log(date)
}
Long Lion

Google Apps Script Moment JS

var cacheExpire = 3600;
var momentCache = "momentCache";
var momentUrl = "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.min.js"

var momentTzCache = "momentTzCache";
var momentTzUrl = "https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.16/moment-timezone-with-data-2012-2022.min.js"

useCachedOrLive(momentCache,momentUrl);
useCachedOrLive(momentTzCache,momentTzUrl);

function useCachedOrLive(cacheToCheck, url){

  var cache = CacheService.getUserCache();
  var cachedData = cache.get(cacheToCheck);
  console.log(cacheToCheck);
  if(cachedData !== null){
    console.log("using cached " + cacheToCheck)
    eval(cachedData);
  }
  else
  {
    console.log("getting live " + cacheToCheck);
    var response = UrlFetchApp.fetch(url).getContentText();
    cache.put(cacheToCheck, response, cacheExpire);
    eval(response);

  }
}
Long Lion

Jawaban yang mirip dengan “Google Apps Script Moment JS”

Pertanyaan yang mirip dengan “Google Apps Script Moment JS”

Lebih banyak jawaban terkait untuk “Google Apps Script Moment JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya