Skip to content

Instantly share code, notes, and snippets.

@asus4
Last active November 14, 2017 19:03
Show Gist options
  • Save asus4/e3399b50e64f052bb8e0 to your computer and use it in GitHub Desktop.
Save asus4/e3399b50e64f052bb8e0 to your computer and use it in GitHub Desktop.
[google apps script] My spreadsheet snippets.
/**
* Simple Check sum
* @param {Array} arguments - 1D Array ex [A0:A6]
* @return {Number} checksum
*/
function CHECK_SUM() {
var arr = arguments[0].map(function(v){return v[0]});
var sum = arr.reduce(function(a, b){ return a + b});
return sum & 0xff;
}
/**
* Convert Date to Unix Time
* @param {DateTiem} arguments - DateTime object
* @return {Number} unixtime
*/
function DATE2UNIXTIME() {
var dt = arguments[0];
var unixtime = Math.floor(dt.getTime() / 1000);
return unixtime;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment