use of org.develnext.jphp.zend.ext.standard.date.DateTimeParseResult in project jphp by jphp-compiler.
the class DateFunctions method date_parse_from_format.
public static Memory date_parse_from_format(Environment env, TraceInfo traceInfo, Memory format, Memory date) {
try {
ZoneId zoneId = zoneId(date_default_timezone_get(env, traceInfo));
DateTimeParseResult result = DateFormat.createParseResultFromFormat(format.toString(), date.toString(), ZonedDateTime.now(zoneId));
return result.toArrayMemory();
} catch (DateTimeException | NoSuchElementException | IllegalArgumentException e) {
return new DateTimeParseResult(null, Collections.emptySet(), null, null).toArrayMemory();
}
}
use of org.develnext.jphp.zend.ext.standard.date.DateTimeParseResult in project jphp by jphp-compiler.
the class DateFunctions method __date.
private static Memory __date(Environment env, TraceInfo traceInfo, ZoneId zoneId, String format, long time) {
ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochSecond(time), zoneId);
DateTimeParseResult parseResult = new DateTimeParseResult(date, Collections.emptySet(), null, null);
return StringMemory.valueOf(DateFormat.formatForDateFunction(env, parseResult, format));
}
Aggregations