Whenever a reduction in force is necessary in any public position, or on public works of the Commonwealth and its political subdivisions, and personnel are discharged according to seniority, the number of years of service of any soldier shall be determined by adding his total years of service in the civil service or on public works to his total years of service as a member of the armed forces of the United States, or in any women's organization officially connected therewith during any war in which the United States engaged.