Wednesday, January 16, 2013

JSON ISO 8601 date formatting, Kendo MVVM using Kendo templates

Here is a quick tip how to bind to JSON ISO 8601 date.

Parsing and formatting to local date is done using Kendo framework.

	<div data-bind="source: expirationDate" data-template="format-date-template"></div>

	<script id="format-date-template" type="text/x-kendo-template">
	<span>#: kendo.toString(kendo.parseDate(data),"d") #</span>
	</script>

and add the warning icon if expired:

	# if (kendo.parseDate(data) < (new Date())) { #
		<span class="icon warning" title="Expired"><span>
	# } #
Links:
Kendo UI
Kendo Templating
Kendo Globalization Date helpers