1/*1789981596000*/ 2/** 3 * Date / time formats often from back from server APIs in a format that you 4 * don't wish to display to your end users (ISO8601 for example). This rendering 5 * helper can be used to transform any source date / time format into something 6 * which can be easily understood by your users when reading the table, and also 7 * by DataTables for sorting the table. 8 * 9 * The [MomentJS library](http://momentjs.com/) is used to accomplish this and 10 * you simply need to tell it which format to transfer from, to and specify a 11 * locale if required. 12 * 13 * This function should be used with the `dt-init columns.render` configuration 14 * option of DataTables. 15 * 16 * It accepts one, two or three parameters: 17 * 18 * * `$.fn.dataTable.render.moment( to );` 19 * * `$.fn.dataTable.render.moment( from, to );` 20 * * `$.fn.dataTable.render.moment( from, to, locale );` 21 * 22 * Where: 23 * 24 * * `to` - the format that will be displayed to the end user 25 * * `from` - the format that is supplied in the data (the default is ISO8601 - 26 * `YYYY-MM-DD`) 27 * * `locale` - the locale which MomentJS should use - the default is `en` 28 * (English). 29 * 30 * @name datetime 31 * @summary Convert date / time source data into one suitable for display 32 * @author [Allan Jardine](http://datatables.net) 33 * @requires DataTables 1.10+, Moment.js 1.7+ 34 * 35 * @example 36 * // Convert ISO8601 dates into a simple human readable format 37 * $('#example').DataTable( { 38 * columnDefs: [ { 39 * targets: 1, 40 * render: $.fn.dataTable.render.moment( 'Do MMM YYYY' ) 41 * } ] 42 * } ); 43 * 44 * @example 45 * // Specify a source format - in this case a unix timestamp 46 * $('#example').DataTable( { 47 * columnDefs: [ { 48 * targets: 2, 49 * render: $.fn.dataTable.render.moment( 'X', 'Do MMM YY' ) 50 * } ] 51 * } ); 52 * 53 * @example 54 * // Specify a source format and locale 55 * $('#example').DataTable( { 56 * columnDefs: [ { 57 * targets: 2, 58 * render: $.fn.dataTable.render.moment( 'YYYY/MM/DD', 'Do MMM YY', 'fr' ) 59 * } ] 60 * } ); 61 */ 62 63 64// UMD 65(function( factory ) { 66 "use strict"; 67 68 if ( typeof define === 'function' && define.amd ) { 69 // AMD 70 define( ['jquery'], function ( $ ) { 71 return factory( $, window, document ); 72 } ); 73 } 74 else if ( typeof exports === 'object' ) { 75 // CommonJS 76 module.exports = function (root, $) { 77 if ( ! root ) { 78 root = window; 79 } 80 81 if ( ! $ ) { 82 $ = typeof window !== 'undefined' ? 83 require('jquery') : 84 require('jquery')( root ); 85 } 86 87 return factory( $, root, root.document ); 88 }; 89 } 90 else { 91 // Browser 92 factory( jQuery, window, document ); 93 } 94} 95(function( $, window, document ) { 96 97 98$.fn.dataTable.render.moment = function ( from, to, locale ) { 99 // Argument shifting 100 if ( arguments.length === 1 ) { 101 locale = 'en'; 102 to = from; 103 from = 'YYYY-MM-DD'; 104 } 105 else if ( arguments.length === 2 ) { 106 locale = 'en'; 107 } 108 109 return function ( d, type, row ) { 110 if (! d) { 111 return type === 'sort' || type === 'type' ? 0 : d; 112 } 113 114 var m = window.moment( d, from, locale, true ); 115 116 // Order and type get a number value from Moment, everything else 117 // sees the rendered value 118 return m.format( type === 'sort' || type === 'type' ? 'x' : to ); 119 }; 120}; 121 122 123}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.