General Periodic Extensions of a function

the original function is defined on [-L, L]:

Clear[f,L];
f[t_] := t /; -3 <= t < 1
f[t_] := (2 - t) /; 1 <= t < 3
L=3;
Plot[f[t],{t,-L,L},PlotStyle->{Red, Thick}]

This function is neither even nor odd.

a general periodic extension

Clear[fPeriodic,x];
fPeriodic[x_]:= f[x] /;(-L≤x<L)
fPeriodic[x_]:= fPeriodic[x-2*L * Sign[x]]/; ((x <-L)||(x >L ))

Plot[{f[t],fPeriodic[t]},{t,-5L,5L},PlotStyle->{{Red, Thick},Blue}]

This extension is neither even nor odd.

Fourier series

calculate the Fourier coefficients

a0 is calculated separately and involves integrating the function. the first term is a0/2.

Clear[a];
a[0]=(1/L)((∫_(-3)^1)t\[DifferentialD]t + (∫_1^3)(2-t)\[DifferentialD]t)

We calculate the other cosine coefficients.  
we integrate f(t) cos(n pi t/L) on [-L, L] and divide by half of the period (half of 2L is L).

a[n_]=(1/L)((∫_(-3)^1)(t Cos[n π t/L])\[DifferentialD]t + (∫_1^3)((2-t)Cos[n π t/L])\[DifferentialD]t)

For sine series, we integrate  f(t) sin(n pi t/L) on [-L, L] and divide by half of the period.

Clear[b];
b[n_]=(1/L)((∫_(-3)^1)(t Sin[n π t/L])\[DifferentialD]t + (∫_1^3)((2-t)Sin[n π t/L])\[DifferentialD]t)

The Fourier partial sums

Clear[PartialSum,t,n,m]
PartialSum[t_,m_]:= (a[0])/2 + Sum[a[n] Cos[n π t/L] + b[n] Sin[n π t/L],{n,1,m}]

PartialSum[t,4]

Simplify[%]

Plot[{fPeriodic[t], PartialSum[t,4]},{t,-3L,3L}]

PartialSum[t,8]

Simplify[%]

the Fourier cosine series fits the general extension

Plot[{PartialSum[t,8],fPeriodic[t]},{t,-5L,5L}]

TO ACTIVATE THE CELL BELOW, change its style to "input".  I suggest you copy, paste, and change the copy.  Then you can delete the entire piece that is dynamic and retain the command form reference.

Manipulate[Plot[{fPeriodic[t], PartialSum[t, n]}, {t, -r*L, r*L}],
 {{n, 4, "number of series terms"}, 1, 15, 2},
 {{r, 1, "number of periods"}, 1, 5, 1}]