Global.String.prototype.toDate (format, timezone)
parse a timestamp into a date object. This is used when users want to set createtime explicitly when creating/editing stories.

  • Parameter String:
    date format to be applied
  • Parameter Object:
    Java TimeZone Object (optional)
  • Returns
    Object contains the resulting date
Sourcecode in /home/hannes/helma/modules/core/String.js:
147:   String.prototype.toDate = function(format, timezone) {
148:       var sdf = res.data._dateformat;
149:       if (!sdf) {
150:           sdf = new java.text.SimpleDateFormat(format);
151:           res.data._dateformat = sdf;
152:       } else if (format != sdf.toPattern())
153:           sdf.applyPattern(format);
154:       if (timezone && timezone != sdf.getTimeZone())
155:           sdf.setTimeZone(timezone);
156:      try {
157:          return new Date(sdf.parse(this).getTime());
158:      } catch (err) {
159:          return null;
160:      }
161:  }