Format HTTP date
"EEE, dd MMM yyyy HH:mm:ss 'GMT'" or
"EEE, dd-MMM-yy HH:mm:ss 'GMT'"for cookies
178558
public static void formatDate(StringBuffer buf,Calendar calendar, boolean cookie)
    {
        // "EEE, dd MMM yyyy HH:mm:ss 'GMT'"
        // "EEE, dd-MMM-yy HH:mm:ss 'GMT'",     cookie
        
        int day_of_week  = calendar.get(Calendar.DAY_OF_WEEK);
        int day_of_month = calendar.get(Calendar.DAY_OF_MONTH);
        int month = calendar.get(Calendar.MONTH);
        int year = calendar.get(Calendar.YEAR);
        int century = year/100;
        year=year%100;

        long tm = (calendar instanceof HttpCal)?(((HttpCal)calendar).getTimeInMillis()):calendar.getTime().getTime();
        int epoch=(int)((tm/1000) % (60*60*24));
        int seconds=epoch%60;
        epoch=epoch/60;
        int minutes=epoch%60;
        int hours=epoch/60;
        
        buf.append(DAYS[day_of_week]);
        buf.append(',');
        buf.append(' ');
        StringUtil.append2digits(buf,day_of_month);
        
        if (cookie)
        {
            buf.append('-');
            buf.append(MONTHS[month]);
            buf.append('-');
            StringUtil.append2digits(buf,year);
        }
        else
        {
            buf.append(' ');
            buf.append(MONTHS[month]);
            buf.append(' ');
            StringUtil.append2digits(buf,century);
            StringUtil.append2digits(buf,year);
        }
        buf.append(' ');
        StringUtil.append2digits(buf,hours);
        buf.append(':');
        StringUtil.append2digits(buf,minutes);
        buf.append(':');
        StringUtil.append2digits(buf,seconds);
        buf.append(" GMT");
    }
1364930
function formatDate(date) {
            let settings = dateFormat || defaultAxisSettings;
            let format = null;
            let localeOptions = {month:'short', day:'numeric'};

            if (settings === axisTimeCombinations.DAY_MONTH || settings === axisTimeCombinations.MONTH_YEAR) {
                format = monthDayYearFormat;
                localeOptions.year = 'numeric';
            } else if (settings === axisTimeCombinations.HOUR_DAY || settings === axisTimeCombinations.MINUTE_HOUR) {
                format = monthDayHourFormat;
                localeOptions.hour = 'numeric';
            } else if (settings === axisTimeCombinations.CUSTOM && typeof dateCustomFormat === 'string') {
                format = d3TimeFormat.timeFormat(dateCustomFormat);
            }

            if (locale && ((typeof Intl !== 'undefined') && (typeof Intl === 'object' && Intl.DateTimeFormat))) {
                let f = Intl.DateTimeFormat(locale, localeOptions);

                return f.format(date);
            }

            return format(date);
        }
32126
function (name, value) {
    var date = new Date(),
      expires = '';
    if (cookieLife) expires = '; expires=' + (new Date(date.getTime() + cookieLife * 60 * 60 * 24 * 1000).toGMTString());
    if (typeof value != undefined) document.cookie = name + '=' + (value.toString().replace(/\s+/g, ' ')) + expires + '; path=/';
  }
422864
def dateDict(date, prefix = ""):
    """"""
    res = {}

    res[prefix+"a"] = date.strftime("%a")
    res[prefix+"A"] = date.strftime("%A")
    res[prefix+"b"] = date.strftime("%b")
    res[prefix+"B"] = date.strftime("%B")
    res[prefix+"c"] = date.strftime("%c")
    res[prefix+"d"] = date.strftime("%d")
    res[prefix+"H"] = date.strftime("%H")
    res[prefix+"I"] = date.strftime("%I")
    res[prefix+"j"] = date.strftime("%j")
    res[prefix+"m"] = date.strftime("%m")
    res[prefix+"M"] = date.strftime("%M")
    res[prefix+"p"] = date.strftime("%p")
    res[prefix+"S"] = date.strftime("%S")
    res[prefix+"U"] = date.strftime("%U")
    res[prefix+"w"] = date.strftime("%w")
    res[prefix+"W"] = date.strftime("%W")
    res[prefix+"x"] = date.strftime("%x")
    res[prefix+"X"] = date.strftime("%X")
    res[prefix+"y"] = date.strftime("%y")
    res[prefix+"Y"] = date.strftime("%Y")
    res[prefix+"Z"] = date.strftime("%Z")

    for i, value in res.items():
        res[i] = locale_to_utf8(value)

    return res
958205
private static String formatDate(Date date) {

        String dateStr = dateFormat.format(date);
        // insert colon into timezone
        return dateStr.substring(0, 22) + ":" + dateStr.substring(22);
    }
1164514
function __Cookies(_cookies) {
  this.cookies = {};
  if (!_cookies || typeof _cookies !== 'string') {
    _cookies = '';
  }

  if (_cookies && _cookies.length) {
    var self = this;
    var i;
    var key;
    var val;

    _cookies.split(/;\ */).forEach(function (pair) {
      i = pair.indexOf('=');
      if (i < 0) {
        return;
      }

      key = unescape(pair.substr(0, i).trim());
      val = pair.substr(++i, pair.length).trim();

      if (val[0] === '"') {
        val = val.slice(1, -1);
      }

      if (self.cookies[key] === void 0) {
        try {
          self.cookies[key] = unescape(val);
        } catch (e) {
          self.cookies[key] = val;
        }
      }
    });
  }
}
1346856
private static String convertV0SetCookie(HttpCookie cookie, boolean isRFC1123DateEnabled) {

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Cookie Name: " + cookie.getName());
            Tr.debug(tc, "Cookie MaxAge: " + cookie.getMaxAge());
            Tr.debug(tc, "RFC1123 Date Enabled (4 digit year): " + isRFC1123DateEnabled);
        }

        StringBuilder buffer = new StringBuilder(40);

        // Append name=value
        buffer.append(cookie.getName());
        String value = cookie.getValue();
        if (null != value && 0 != value.length()) {
            buffer.append('=');
            buffer.append(value);
        } else {
            // PK48196 - send an empty value string
            buffer.append("=\"\"");
        }

        // check for optional comment
        String comment = cookie.getComment();
        if (null != comment && 0 != comment.length()) {
            buffer.append("; Comment=");
            maybeQuote(buffer, comment);
        }

        // check for optional max-age/expires
        int expires = cookie.getMaxAge();
        if (-1 < expires) {
            if (0 == expires) {
                if (!isRFC1123DateEnabled) {
                    buffer.append(longAgo);
                } else {
                    buffer.append(longAgoRFC1123);
                }
            } else {
                buffer.append("; Expires=");
                if (!isRFC1123DateEnabled) {
                    buffer.append(HttpDispatcher.getDateFormatter().getRFC2109Time(new Date(HttpDispatcher.getApproxTime() + (expires * 1000L))));
                } else {
                    buffer.append(HttpDispatcher.getDateFormatter().getRFC1123Time(new Date(HttpDispatcher.getApproxTime() + (expires * 1000L))));
                }
            }
        } else if (cookie.isDiscard()) {
            // convert discard to immediate expiration
            if (!isRFC1123DateEnabled) {
                buffer.append(longAgo);
            } else {
                buffer.append(longAgoRFC1123);
            }
        }

        // check for optional path
        value = cookie.getPath();
        if (null != value && 0 != value.length()) {
            buffer.append("; Path=");
            buffer.append(value);
        }

        // check for optional domain
        value = cookie.getDomain();
        if (null != value && 0 != value.length()) {
            buffer.append("; Domain=");
            buffer.append(value);
        }

        if (cookie.isSecure()) {
            buffer.append("; Secure");
        }

        if (cookie.isHttpOnly()) {
            buffer.append("; HttpOnly");
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Created v0 Set-Cookie: [" + GenericUtils.nullOutPasswords(buffer.toString(), (byte) '&') + "]");
        }
        return buffer.toString();
    }
564003
def date_0utc(date):
    
    return ee.Date.fromYMD(date.get('year'), date.get('month'),
                           date.get('day'))
20116
function (name, value) {
      var date = new Date();
      date.setTime(date.getTime() + this.cookieTimeout);

      document.cookie = name + '=' + value + ';expires=' + date.toGMTString() + ';path=/';
    }
902467
def server_date_utc(self):
        """"""
        date_str = self.request('http://www.shanbay.com', 'head'
                                ).headers['date']
        date_utc = datetime.datetime.strptime(date_str,
                                              '%a, %d %b %Y %H:%M:%S GMT')
        return date_utc
1258583
def lwp_cookie_str(cookie):
    
    h = [(cookie.name, cookie.value),
         ("path", cookie.path),
         ("domain", cookie.domain)]
    if cookie.port is not None: h.append(("port", cookie.port))
    if cookie.path_specified: h.append(("path_spec", None))
    if cookie.port_specified: h.append(("port_spec", None))
    if cookie.domain_initial_dot: h.append(("domain_dot", None))
    if cookie.secure: h.append(("secure", None))
    if cookie.expires: h.append(("expires",
                               time2isoz(float(cookie.expires))))
    if cookie.discard: h.append(("discard", None))
    if cookie.comment: h.append(("comment", cookie.comment))
    if cookie.comment_url: h.append(("commenturl", cookie.comment_url))

    keys = sorted(cookie._rest.keys())
    for k in keys:
        h.append((k, str(cookie._rest[k])))

    h.append(("version", str(cookie.version)))

    return join_header_words([h])
43068
def rfc2822(self):

        ''' 
            
        '''

    # define format
        js_format = '%a, %d %b %Y %H:%M:%S GMT'
        utc_time = self.astimezone(pytz.utc)

        return format(utc_time, js_format)
926024
def set_cookie(self, key, value, expiration='Infinity', path='/', domain='', secure=False):
        

        secure = 'true' if secure else 'false'
        self.app_instance.execute_javascript("""
            var sKey = "%(sKey)s";
            var sValue = "%(sValue)s";
            var vEnd = eval("%(vEnd)s");
            var sPath = "%(sPath)s"; 
            var sDomain = "%(sDomain)s"; 
            var bSecure = %(bSecure)s;
            if( (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) == false ){
                var sExpires = "";
                if (vEnd) {
                    switch (vEnd.constructor) {
                        case Number:
                            sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd;
                        break;
                        case String:
                            sExpires = "; expires=" + vEnd;
                        break;
                        case Date:
                            sExpires = "; expires=" + vEnd.toUTCString();
                        break;
                    }
                }
                document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
            }
            """%{'sKey': key, 'sValue': value, 'vEnd': expiration, 'sPath': path, 'sDomain': domain, 'bSecure': secure})
26408
function getExpiryDate(store, data) {
        
        var offset;

        if (data.cookie.originalMaxAge) {
            offset = data.cookie.originalMaxAge;
        } else {
            offset = store.sessionTimeOut * 60000;
        }
        
        return offset ? new Date(Date.now() + offset) : null;
    }
653519
public static String formatCookieDate(long date) {
        StringBuilder buf = new StringBuilder(28);
        formatCookieDate(buf, date);
        return buf.toString();
    }
606543
function (d, use_UTC) {
		if (typeof d === "string") {
			if (d.match(/[0-9][0-9][0-9][0-9][\s]*-[0-1][0-9]-[\s]*[0-3][0-9]/)) {
				return d.replace(/\s+/, "");
			}
			d = new Date(d);
		} else if (typeof d === "number") {
			d = new Date(d);
		} else if (typeof d !== "object" &&
				typeof d.getFullYear !== "function") {
			throw "Expecting type: " + String(d) + " --> " + typeof d;
		}
		if (!use_UTC) {
			return [
				d.getFullYear(),
				String("0" + (d.getMonth() + 1)).substr(-2),
				String("0" + d.getDate()).substr(-2)
			].join("-");
		}
		return [
			d.getUTCFullYear(),
			String("0" + (d.getUTCMonth() + 1)).substr(-2),
			String("0" + d.getUTCDate()).substr(-2)
		].join("-");
	}
1327416
function cookie(name, value, ttl, path, domain, secure) {
    if (arguments.length > 1) {
        let newCookie = name + '=' + encodeURIComponent(value) +
            (ttl ? "; expires=" + new Date(+new Date()+(ttl*1000)).toUTCString() : '') +
            (path   ? "; path=" + path : '') +
            (domain ? "; domain=" + domain : '') +
            (secure ? "; secure" : '');
        document.cookie = newCookie;
        return newCookie;
    }
    return decodeURIComponent((("; "+document.cookie).split("; "+name+"=")[1]||"").split(";")[0]);
}