When using App Connect addMinutes as negative works, positive does not

Wappler 5.8.2, Mac M1

When using the client side formatter for addMinutes, it only calculates negative numbers, and not positive, to force it to calculate the positive numbers, it requires an additional formatter of toNumber(), which makes sense as to get the negative, it would have had to multiply by -1 already, which would have already turned it into a number and not a string.

This Works

dmx.parse("content.sc_staff_shift_attached_events.data.query_attached_to_staff_shift[1].av_start_time_local.replace('Z','').addMinutes(-content.sc_staff_shift_attached_events.data.query_attached_to_staff_shift[1].staff_position[0].pissp_pre_time).formatDate('HH:mm')")
'11:31'

This does not

dmx.parse("content.sc_staff_shift_attached_events.data.query_attached_to_staff_shift[1].av_start_time_local.replace('Z','').addMinutes(content.sc_staff_shift_attached_events.data.query_attached_to_staff_shift[1].staff_position[0].pissp_pre_time).formatDate('HH:mm')")
'12:00'

To force it to work, adjust to

dmx.parse("content.sc_staff_shift_attached_events.data.query_attached_to_staff_shift[1].av_start_time_local.replace('Z','').addMinutes(content.sc_staff_shift_attached_events.data.query_attached_to_staff_shift[1].staff_position[0].pissp_pre_time.toNumber()).formatDate('HH:mm')")
'12:29'

Hope that makes sense, and helps someone else if they are struggling with it.

Well most probably this returns a string, not a number :slight_smile:

1 Like

It does indeed return a string, its just made me lazy, because if I make it negative even as a string it tuns it into a number automatically, so when I remove the minus sign, then suddenly it does not work, which made sense, after I thought about it for a moment.
Wondering if it may be an idea, to have the addMinutes formatter always auto convert to a number regardless of positive or negative to avoid confusion, and make me even more lazy, haha.

As i said in another topic:

1 Like