<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>21367</bug_id>
          
          <creation_ts>2013-03-21 22:27:50 +0000</creation_ts>
          <short_desc>Date object doesn&apos;t zupport timezones</short_desc>
          <delta_ts>2014-06-21 12:52:22 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>JavaScript</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jim Michaels">jmichae3</reporter>
          <assigned_to name="Mathias Bynens">mathias</assigned_to>
          <cc>mike</cc>
          
          <qa_contact>sideshowbarker+javascript</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>84800</commentid>
    <comment_count>0</comment_count>
    <who name="Jim Michaels">jmichae3</who>
    <bug_when>2013-03-21 22:27:50 +0000</bug_when>
    <thetext>Date object doesn&apos;t zupport timezones
many people want to support timezones in their javascript applications, for world clocks, appointments, corporate business calendars, etc.
but the Date object doesn&apos;t support this.
apparently browser vendors don&apos;t all support .toISOSTring().
.toISOSTring should support parameters such as a timezone, for conversion to timezones. 
ISO8601-2004 supports suffix timezones in the format as 
Z for GMT.UTC or
+hhmm
-hhmm
+hh
-hh
for instance, in the extended years format in 15.9.1.15.1 in ecmascript 262 specification for javascript you see a Z on the end. 
I am proposing allowing these timezones in Date.prototype.parse().

there should also be 
.getTimeZone() and 
.setTimeZone(integerTimeZoneHHMMoffset) methods for the Date object.

and because the extended format requires zero padding and there are no zero padding functions, I am suggesting the following zero padding function of mine.

I still need to use this zeropad function in my own code in various forms, because various languages again don&apos;t have this function. I write for many languages. I hope to improve those too.

function str_repeat(s,n) {
	var s2=&quot;&quot;;
	for (var __i=1; __i &lt;= n; __i++) {
		s2+=s;
	}
	return s2;
}
function zeropad(n, numdigits) {//requires: nothing. returns string. on failure, alert()
	var s=&quot;&quot;;
	var i;
	if (null==n) {
		//alert(&quot;zeropad(): undefined n&quot;);
		return &quot;&quot;;
	}
	if (null==numdigits) {
		//alert(&quot;zeropad(): undefined numdigits&quot;);
		return &quot;&quot;;
	}
	var nstr = n.toString();
	var nInt = parseInt(n);
	var nIntStr = nInt.toString();
	var numdigitsInt = parseInt(numdigits);
	if (isNaN(nInt)) { //must be hexadecimal or something else
		//nIntStr = nstr;
		s=str_repeat(&apos;0&apos;,Math.max(nstr.length,numdigitsInt) - Math.min(nstr.length,numdigitsInt));
		return s+nstr;
	} else {
		if (Math.abs(n) &gt; Math.abs(nInt)) {
			//has digits past decimal point
			if (&quot;-&quot; == nstr.substring(0,1)) {
				//is negative
				if (nstr.length &lt; numdigits) {
					s = str_repeat(&apos;0&apos;,numdigitsInt - (nstr.length+1));
				}
				return &quot;-&quot; + s + nstr.substring(1,nstr.length);
			} else {
				if (nstr.length &lt; numdigits) {
					s = str_repeat(&apos;0&apos;,numdigitsInt - (nstr.length+1));
				}
				//is positive and has no + sign in front
				return s + nstr;
			}
		} else {
			//has no digits past decimal point
			if (&quot;-&quot; == nstr.substring(0,1)) {
				//and is negative
				if (numdigitsInt-nIntStr.length &gt;= 1) {
					s = str_repeat(&apos;0&apos;,numdigitsInt - nIntStr.length);
				}
				return &quot;-&quot; + s + nIntStr.substring(1,nIntStr.length);
			} else {
				//and is positive
				if (numdigitsInt-nIntStr.length &gt;= 1) {
					s = str_repeat(&apos;0&apos;,numdigitsInt - nIntStr.length);
				}
				return s + nIntStr;
			}
		}
	}
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84805</commentid>
    <comment_count>1</comment_count>
    <who name="Jim Michaels">jmichae3</who>
    <bug_when>2013-03-21 23:33:58 +0000</bug_when>
    <thetext>I would also add that the Date.prototype.getUTC (append a time,as in Seconds, Month, FullYear, whatever) should also be available as Date.prototype.getTZ (append a time as shown previously), where one of the parameters is an integer timezone offset in the form +-hhmm where you have the choice of doing hhmm as
timezoneoffset=hh*60+mm
or
timezoneoffset=hh*100+mm
I would suggest the former.

so this is also part of the proposal. I just realized this is also necessary for implementing time zone functionality.

I think this could also affect Date.prototype.toJSON(key) in that a new optional parameter would be added, a timezone, if I am understanding this correctly.

a correction to previous post, &quot;apparently browser vendors don&apos;t all support .toISOSTring().&quot;: .toISOSTring() should be .toISOString(), it had a typo.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84812</commentid>
    <comment_count>2</comment_count>
    <who name="Jim Michaels">jmichae3</who>
    <bug_when>2013-03-22 00:23:50 +0000</bug_when>
    <thetext>I am thinking that there could also be a timezone parameter in the Date 

Date.prototype.MakeDay() and Date.prototype.MakeTime() would need a new kind of timezone version maybe called Date.prototype.MakeTimeTZ(year, month[, date[, hours[, minutes[, seconds[,milliseconds[, tzHours[, [tzMinutes]]]]]]])
because timezone depends upon th date, and generates hours and minutes.

there would need to be a Date.TZ(year, month[, date, [hours[, minutes[, seconds[, milliseconds[, tzHours[, [tzMinutes]]]]]]]) which returns a TimeClip.

there would need to be a change to 15.9.3.1, the Date constructor, 
new Date(year, month, [date[, hours[, minutes[, seconds[, milliseconds[, tzHours[, [tzMinutes]]]]]]])

and 15.9.2.1, the Date constructor called as a function:

Date([year[, month[, date[, hours[, minutes[, seconds[, milliseconds[, tzHours[, [tzMinutes]]]]]]]]]])</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90217</commentid>
    <comment_count>3</comment_count>
    <who name="Jim Michaels">jmichae3</who>
    <bug_when>2013-07-03 09:29:06 +0000</bug_when>
    <thetext>somehow the comment I just submitted which would have made this more functional got dropped somehow.

Date should be fully timezone-aware and DST-aware. (Daylight Saving Time)

currently, Date.prototype.getTimezoneOffset() only provides the difference in minutes between local time and UTC.

I would like to see the following functionality also added, which would be helpful for making clocks, dealing with time and such:

Date.prototype.SetTimezoneOffset(minutesOffset) which minutesOffset can be calculated as hours*60+minutes and returns nothing (or you can return the output of .getTimezoneOffset())
essentially it does the opposite of Date.prototype.getTimezoneOffset()
I would have preferred this function and Date.prototype.getTimezoneOffset() actually set the timezone offset and not both the DST and timezone offset at the same time.
if that were to change to be timezone-only, one of 2 things can happen:
- change is made and existing code will break, and people will simply have to change their code.
- no change is made and this function prototype simply does the opposite of the current .getTimezoneOffset(), as messy as that is.
...maybe we DO need this function in the way I didn&apos;t prefer (I only wanted the nice function name, because it fits so well working with timezones).


Date.prototype.isDST() returns a Boolean indicating whether or not DST is in effect or not.

Date.prototype.enableDST(enable) where enableDST is Boolean that enables DST.

Date.prototype.getDSTOffsetMinutes() returns the number of minutes offset of the DST.

Date.prototype.setDSTOffsetMinutes(minutes) returns getDSTOffset or nothing, and minutes is the minutes DST offset you wish to set. 
it will only apply if DST is applicable to the timezone. 
the timezone must be applied first for this function to work properly.

Date.prototype.setTimezoneOffsetMinutes(minutes) this sets the timezone ONLY, not TZ and DST. is is presumed that Date is DST-aware.

Date.prototype.getTimezoneOffsetMinutes(minutes) this gets the timezone offset ONLY, not TZ and DST. is is now presumes that Date is DST-aware.

btw, I think this needs to be added to Java&apos;s Calendar and Date as well, it lacks the functionality needed for DST.


one possibility is, I just looked up Java equivalents that would fit this needed separate DST and TZ functionality within the Date object that are needed.
http://docs.oracle.com/javase/6/docs/api/java/util/TimeZone.html
http://docs.oracle.com/javase/6/docs/api/java/util/Calendar.html
http://docs.oracle.com/javase/6/docs/api/java/util/GregorianCalendar.html
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5029449

these functions and classes I think would add the needed time functionality to javascript, and Java needs them as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108172</commentid>
    <comment_count>4</comment_count>
    <who name="Mathias Bynens">mathias</who>
    <bug_when>2014-06-21 12:52:22 +0000</bug_when>
    <thetext>This is outside the scope of the JavaScript / Web ECMAScript spec. See &lt;http://javascript.spec.whatwg.org/#goals&gt;.

To propose new features to the ECMAScript language, please file a bug on https://bugs.ecmascript.org/.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>