Nodejs Timezone Calculate ToDfpDate(timeZoneID)

Here you can find the source of ToDfpDate(timeZoneID)

Method Source Code

Date.prototype.ToDfpDate = function (timeZoneID) {
  if (!isNaN(this.valueOf())) {
    return {/*from   w  w  w. ja  v  a2s . c om*/
      date: {
        year : this.getFullYear(),
        month : this.getMonth(),
        day : this.getDate()
      },
      hour : this.getHours(),
      minute : this.getMinutes(),
      second : this.getSeconds(),
      timeZoneID : timeZoneID
    };
  }

  throw new Error('Empty a date type');
};

Date.prototype.FromDfpDate = function (dfpDate) {
  return new Date(dfpDate.date.year, dfpDate.date.month, dfpDate.date.day, dfpDate.hour, dfpDate.minute, dfpDate.second);
};

Related

  1. getD(zone)
    Date.prototype.getD = function(zone) {
      zone = typeof zone !== 'undefined' ? zone : this.getTimezoneOffset();
      return Math.floor((this.getTime()-zone*60000)/86400000);
    
  2. getDSTTimezoneOffset()
    Date.prototype.getDSTTimezoneOffset = function() {
      var jan = new Date(this.getFullYear(), 0, 1);
      var jul = new Date(this.getFullYear(), 6, 1);
      return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
    document.cookie = "auto_timezone_offset=" + -60 * new Date().getDSTTimezoneOffset();
    
  3. getStdTimezone()
    Date.prototype.getStdTimezone = function() {
        var jan = new Date(2015, 0, 1);
        var jul = new Date(2015, 6, 1);
        return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
    
  4. getTimezone()
    Date.prototype.getTimezone = function () {
        return this.toString().replace(
            /^.*? ([A-Z]{3}) [0-9]{4}.*$/, "$1").replace(
            /^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3");