How to calculate the time that a piece of wire can last before it melts when constant current is applied
It's a complicated problem. An exact solution needs lots of details. Approximate solutions can be done by making some sweeping assumptions. 

Wikipedia (AWG) has tables for rated 'current carrying' and 'fusing' for various wire sizes. Of course, they are very approximate and depend on the details.

The first is whether heating is fast, slow or intermediate

With Fast heating, no heat is lost from the wire during heating. We assume there's no cooling by convection, no conduction along the wire to the terminals, no loss to radiation. As the heating period becomes shorter, this becomes a better approximation. This is the adiabatic regime. Only heat capacity is relevant, not the length of wire.

In the adiabatic case, the \$I^2t\$ to fusing stays constant, see if you can demonstrate why. The fast fusing current is estimated with this approximation.

With Slow heating, the wire comes to equilibrium between heat input and conduction to the terminals, convection to the air, and radiation cooling.  Only thermal losses are relevant, you can simply equate heat input to losses, and then work out what heat input is required at the temperature of melting point. Assumptions have to be made about the length of wire and the heat-sinking ability of the terminals, and its environment. The slow fusing current is estimated with this approximation.

Obviously with intermediate rate heating, you have to take account of both thermal capacity and losses.

With constant current, the amount of heat going into the wire varies as the wire resistance. For copper, at room temperature, the resistance increases 10% for 25C increase. I don't have in my head how much the resistance increases between room temperature and melting point, it's not just a linear extrapolation of the room temperature behaviour, but it does continue to increase.

It's fairly easy to obtain, from Kaye and Laby online for instance, tables of melting points, thermal capacities, thermal conductivities and resistances at various temperatures.

In the fully detailed case, you would take a timestep, work out the heat depositied, and the heat lost, work out the temperature rise, and with the new resistance do the next time step. The most difficult factors to obtain accurately would be the convection.

A good simple one to compute first is therefore the adiabatic case. As a first approximate cut, assume constant resistance and constant heat capacity, take some average for both at some intermediate temperature, which is simple enough to be written down on the back of an envelope. Compare that result with the wikipedia figures to make sure you have the right powers of 10. Then do a simulation letting resistance, thermal capacity, or both, vary with temperature. Compare that result with your back of envelope, to make sure you're in the right ballpark. Thus practiced, you can try more realistic simulations.

Once you've done a few simulations with varying details, I suspect you'll just use the wikipedia figures, with the knowledge that they are very approximate, but close enough.