Secretary of the Navy Ray Mabus announced in May that he was planning to increase paid maternity leave for sailors from six to 12 weeks. It was one of a number of changes designed to make his branch of the armed forces more attractive to women — and to keep them once they signed up.

Then he doubled down. When Mabus finally unveiled his new policy this month, it was even more generous than promised — 18 weeks, effective immediately and retroactively to the beginning of 2015. Generous, that is, by U.S. standards. This is the only industrialized country that doesn’t mandate paid maternity leave for workers. Who would’ve guessed the armed forces would become the model for a progressive family-leave policy?

The upgrade is thanks in large part to Silicon Valley. In the intervening weeks between the announcement and the policy change, Mabus realized that if he wanted to compete with tech companies for skilled female workers, he had to do better than 12 weeks. Google, for example, offers mothers between 18 and 22 weeks of leave. Other companies such as Facebook offer similarly long parental leaves, for dads as well.

Thanks to Mabus’ decision, the Air Force is now considering 18 weeks of maternity leave. Ideally, other employers will also reconsider their policies.

Eighteen weeks of paid leave might seem like a financial burden for employers. But the Navy’s calculation is that the one- or two-time cost (the typical American mom has two kids) is a long-term bargain that pays off in savings from not having to retrain replacement workers. When Google hiked its maternity leave, the rate at which new moms left the company was cut in half.

Women make up about half of the U.S. workforce but only about 25 percent of new recruits and only 18 percent of the Navy’s workforce. Female sailors leave the service in great numbers in years five and six, and the top reason is “family.” Family is also the No. 2 reason that men leave the Navy, and Mabus is pushing for more leave for new fathers as well as for sailors who adopt children.

Staying put in a job pencils out for women, too. When women quit a job to take care of family, their earning power is severely diminished when they return to the workforce. Research indicates that when mothers have access to paid maternity leave, their wages increase as much as 9 percent.

Paid parental leave also leads to lower infant mortality rates, healthier children and a happier workforce. Yet only about 12 percent of U.S. workers have this benefit. Most of them are in the four states, including California, that have publicly funded some level of paid family leave.

That’s dismal. We should do better.

FROM AN EDITORIAL IN THE LOS ANGELES TIMES