function timestamp = get_timestamp (self, frame, applyCorrection)
    % timestamp = GET_TIMESTAMP (self, frame, applyCorrection)
    %
    % Retrieve timestamp corresponding to specified frame.
    %
    % Input:
    %  - self = @TimestampDatabase instance
    %  - frame = frame number(s)
    %  - applyCorrection = whether to apply date and time offset to
    %    timestamp. Default value is false, meaning that raw timestamp is
    %    returned. Timestamps with applied correction are usually used for
    %    display purposes, whereas raw timestamps are used for data
    %    retrieval.
    %
    % Output:
    %  - timestamp = timestamp, in Unix Epoch
    %
    % Copyright (C) 2011-2012, Rok Mandeljc <rok.mandeljc@fe.uni-lj.si>

    % Default parameter for applyCorrection
    if nargin < 3,
        applyCorrection = false;
    end
    
    % Apply frame offset
    frame = frame - self.frameOffset;
    
    % Check frame number
    if any(frame < 1) || any(frame > numel(self.data)),
        error('Rok:Timestamp:InvalidFrameNumber', 'Invalid frame number; must be a number between %d and %d!', 1+self.frameOffset, numel(self.data)+self.frameOffset);
    end
    
    timestamp = self.data(frame);
    
    % Apply date and time offset
    if applyCorrection,
        timestamp = timestamp + self.timeOffset + self.dateOffset*86400;
    end
end