Ticket Created
over 3 years ago

WERETECH-12628

LocalMoment is wrong

The documentation fails to provide an initializing Constructor and the example is wrong.

a) It requires (where, when) not (when, where).

b) it doesn't take a Gregorian.moment as the when argument.

This, from the documentation fails:

if (Gregorian has :localMoment){
		var options = {
			:year   => 2018,
			:month  => 2,
			:day    => 24,
			:hour   => 0,
			:min    => 12 
		};
		var when = Gregorian.moment(options);
		
		var where = new Position.Location({
			:latitude  =>  38.85391,
			:longitude => -94.79630,
			:format    => :degrees,
		});

		var local = Gregorian.localMoment(when, where);
		var info = Gregorian.info(local, Time.FORMAT_SHORT);
	}

This works

if (Gregorian has :localMoment){
		var options = {
			:year   => 2018,
			:month  => 2,
			:day    => 24,
			:hour   => 0,
			:min    => 12 
		};
		var when = Gregorian.moment(options);
		
		var where = new Position.Location({
			:latitude  =>  38.85391,
			:longitude => -94.79630,
			:format    => :degrees,
		});

		var local = Gregorian.localMoment(where, when.value());
		var info = Gregorian.info(local, Time.FORMAT_SHORT);
	}

- note (where, when), not (when, where) , and a number not a moment.

Parents
  • I just hit this bug for anyone wondering. Calling the API as per the docs crashes on device "unhandled exception". However calling value() as described above works fine. However, you have to do a disgusting trick like this to make the type checker happy:

    var z = m1.value() as Lang.Number or Time.Moment;
    var t1 = Time.Gregorian.localMoment(l1, z);

Comment
  • I just hit this bug for anyone wondering. Calling the API as per the docs crashes on device "unhandled exception". However calling value() as described above works fine. However, you have to do a disgusting trick like this to make the type checker happy:

    var z = m1.value() as Lang.Number or Time.Moment;
    var t1 = Time.Gregorian.localMoment(l1, z);

Children
No Data