B2G/gecko/dom/mobilemessage/src/ril/MmsPduHelper.jsm
/**
   * @param data
   *        A wrapped object to store encoded raw data.
   * @param value
   *        A Date object for absolute expiry or an integer for relative one.
   */
@param data
A wrapped object to store encoded raw data.
@param value
A Date object for absolute expiry or an integer for relative one.
@param data A wrapped object to store encoded raw data . @param value A Date object for absolute expiry or an integer for relative one .
function encode(data, value) {
    let isDate, begin = data.offset;
    if (value instanceof Date) {
      isDate = true;
      WSP.DateValue.encode(data, value);
    } else if (typeof value == "number") {
      isDate = false;
      WSP.DeltaSecondsValue.encode(data, value);
    } else {
      throw new CodeError("Expiry-value: invalid value type");
    }
    let len = data.offset - begin;
    data.offset = begin;
    WSP.ValueLength.encode(data, len + 1);
    if (isDate) {
      WSP.Octet.encode(data, 128);
      WSP.DateValue.encode(data, value);
    } else {
      WSP.Octet.encode(data, 129);
      WSP.DeltaSecondsValue.encode(data, value);
    }
  }
function encode ( data , value ) { let isDate , begin = data . offset ; if ( value instanceof Date ) { isDate = true ; WSP . DateValue . encode ( data , value ) ; } else if ( typeof value == "number" ) { isDate = false ; WSP . DeltaSecondsValue . encode ( data , value ) ; } else { throw new CodeError ( "Expiry-value: invalid value type" ) ; } let len = data . offset - begin ; data . offset = begin ; WSP . ValueLength . encode ( data , len + 1 ) ; if ( isDate ) { WSP . Octet . encode ( data , 128 ) ; WSP . DateValue . encode ( data , value ) ; } else { WSP . Octet . encode ( data , 129 ) ; WSP . DeltaSecondsValue . encode ( data , value ) ; } }
@param data
        A wrapped object to store encoded raw data.
@param data A wrapped object to store encoded raw data .
// Calculate how much octets will be written and seek back. // TODO: use memmove, see bug 730873