#3706·moment

.startOf("hour") expected result across some dst boundaries?

Author: colinhuntCreated Jan 6, 2017Updated Aug 12, 2026
LabelsBugDST

Description of the Issue and Steps to Reproduce:

Just wondering if this is actually an issue that might be related to #1990 :

m = moment.tz("2017-04-02T01:30:00+10:30", "Australia/Lord_Howe")
m.format()
> "2017-04-02T01:30:00+10:30"
m.startOf("hour").format()

Actual

> "2017-04-02T01:30:00+11:00"

Expected:

> "2017-04-02T01:00:00+11:00"

Note, because of the time shift, the times progress like this in 30 minute intervals:

0100+11:00 0130+11:00 0130+10:30 0200+10:30 ...

It occurs to me that 01:30+11:00 may indeed be the start of the hour, because 01:30+10:30 is halfway between 0130+11:00 and 0200+10:30. However, this is contrary to the documentation which states that startOf sets all lesser units to 0.

What is expected here?

Environment: Chrome 53.0.2785.113 (64-bit) on Ubuntu 14.04

Other information that may be helpful:

  • The time zone setting of the machine the code is running on MST

  • The time and date at which the code was run Fri Jan 6 14:00

  • Other libraries in use (TypeScript, Immutable.js, etc)

	<script language="javascript" type="text/javascript" src="jquery.js"></script>
	<script language="javascript" type="text/javascript" src="jquery.flot.js"></script>
	<script language="javascript" type="text/javascript" src="../../../projects/flot/jquery.flot.temporal.js"></script>
	<script language="javascript" type="text/javascript" src="../../../projects/git/flot/jquery.flot.temporal.js"></script>
	<script language="javascript" type="text/javascript" src="jquery.flot.navigate.js"></script>
	<script language="javascript" type="text/javascript" src="jquery.flot.time.js"></script>
	<script language="javascript" type="text/javascript" src="jquery.flot.navigationControl.js"></script>
	<script language="javascript" type="text/javascript" src="moment.js"></script>
	<script language="javascript" type="text/javascript" src="moment-timezone-with-data.js"></script>

If you are reporting an issue, please run the following code in the environment you are using and include the output:

console.log( (new Date()).toString())
console.log((new Date()).toLocaleString())
console.log( (new Date()).getTimezoneOffset())
console.log( navigator.userAgent)
console.log(moment.version)

Fri Jan 06 2017 15:03:48 GMT-0700 (MST)
VM1792:2 1/6/2017, 3:03:48 PM
VM1792:3 420
VM1792:4 Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.113 Safari/537.36
VM1792:5 2.17.1