How long can an LED withstand its rated peak current?
Conclusion

20% @ 40mA is not safe.  Proof at the end.

The AlGaAs Red a.k.a. ultrabright Red operates at a higher voltage than GaAs.

These parts have the following TYP. specs @ 25'C:


1.6 V @ 1 mA  (1.6 mW)
1.7 V @ 5 mA  (8.5 mW)
1.8 V to 2.2 Vmax @ 20 mA (36 to 44 mW)
Derate above 91°C at 0.53 mA/°C
255 to 430 °C/W/Seg  depending on device
Average power /seg 37 mW is an ABSOLUTE MAXIMUM



  You asked is 20% duty cycle safe for 40mA?


So let's extrapolate the Pd at 40mA. Using linear regression, the Vf=1.7V(@ 5mA)+ΔV/ΔI  = 2.2Vmax (@ 20mA) thus Vf= 1.7V + 30Ω * If = 1.7+ 30* 0.04A= 2.8V
(112mW) 

Thus 20% duty cycle = 22.4 mW which is less than the ABS MAX of 37mW. OK so far.

the gotcha

But that's only for 1 segment.  

So if we activate 7 segments + dot = 8 x 22.4mW=179mW . 

We know the current derating is above 91'C yet the max operating temp is 100'C. 

They also spec the thermal resistance from junction to pin as 255 to 430 °C/W/Seg

Let's pick 345'C/W. So with 179mW,  all 8 junctions rise 345'/W*0.179W=62'C above 25'C pin temp (big assumption) which makes the junction pretty close to 100'C and then the pin/pads start to heat up. 

(boiling hot is bad for popcorn failures from common moisture ingress may results in LED chip delamination, as clear epoxy has poorer moisture seal on the interface compared to black epoxy.)

Recommendation:

Verify Vf max on every lot is closer to typ and not max @ 40mA and/or don't exceed 30mA at 20% duty cycle or don't use 20% PWM @40mA.  using 50% at 15mA for the same brightness.  Use fat thermal tracks for each segment to radiate some heat.

Other info

Stanley and HP pioneered the GaAs RED LED's so that others could multiplex them in the 1st LED digital watch in the early 70's. Since they had Vf= 1.6V vs AlGas of 2V they could handle more current but were far less bright. ( My buddy Kirk did the 1st LED watch at Litronix bought by Siemens A.G. of Germany.)

The problem was to make the gold whisker wire bond small enough to be almost invisible yet carry enough peak current not to fuse. Meanwhile the chip itself is thermal insulator is tiny so it cannot handle much power owing to the high tempco of >250/C/W.

The result is your average 5mm LED has an Abs. Max. to rated current ratio of 30/20=1.5   These parts have a ratio of 45/15=3 which permits MUXing to an absolute max of 3 digits as reasonable intensity but only 2 at max intensity.