Calculate battery discharging time?
Battery discharge time is fairly easy to calculate in principle, assuming the load draws constant current. This means the load will always draw the same amount of current as long as the battery voltage is within the range allowed by the load specifications. "Load" is a general term for eveything powered by the battery.

You need to know how much current your load draws on average. Placing a voltmeter in series with the load will tell you the current, unit mA. If the number is negative, you hooked up the voltmeter the wrong way or something is off; maybe the battery is being charged from USB or a wall plug?

You also need to know the capacity of the battery, in unit mAh.

Now just divide the battery capacity by the current to get the battery time.

Example: 1000 mAh battery and 100 mA load gives 1000 / 100 = 10 hours of battery time.

It's common for circuits to draw slightly more when the battery is fresh and gives higher voltage, but we can simplify by using the average ("nominal") battery voltage. Some circuits also draw different amount of current depending on mode, such as sending radio packets, entering power-save or activating a display. The calculation must be done with the average current, or be carried out for each system mode separately.

A more advanced analysis would look at battery self-discharge rate, internal resistance, temperature, etc. For example, a coin cell battery will drain very quickly if put under heavy load, but last for years if used correctly. Anyway, the basic calculation should give a rough, slightly overestimated battery time.