Download code/validation/JavaScript/0041706_format.jam.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/validation/JavaScript/0041706_format.jam.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/code/validation/JavaScript/0041706_format.jam.js
-
curl -L -o 0041706_format.jam.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/validation/JavaScript/0041706_format.jam.js
1.63 kB
| /** | |
| * Generator of date-formatters. | |
| * Date-formatter is a function that returns string representation of a date. | |
| * | |
| * 0 params: hash-table of all patterns | |
| * 1 param: return date-formatter by pattern | |
| * 2 params: assign date-formatter for pattern | |
| * | |
| * Mnemonics: | |
| * | |
| * * single letter for numbers: M - month number, D - day of month. | |
| * * uppercase letters for dates, lowercase for times: M - month number , m - minutes number | |
| * * repeated letters for define register count: YYYY - full year, YY - shot year, MM - padded month number | |
| * * words, same letter case: Month - localized capitalized month name | |
| * * shortcuts: WD - short day of week, Mon - short month name. | |
| * * special identifiers: iso8601, stamp. | |
| * | |
| * Complex patterns splits by words and then substitute by date-formatters for short patterns | |
| * For localize output override $jin.l10n( scope, text ) | |
| * | |
| * Typical usage: | |
| * var formatTime = $jin.time1.format( 'Weekday, YYYY-MM-DD hh:mm' ) | |
| * formatTime( $jin.time1.moment() ) | |
| * | |
| * @name $jin.time1.format | |
| * @method format | |
| * @member $jin.time | |
| * @param {string} [pattern] | |
| * @param {function( $jin.date )} [formatter] | |
| * @static | |
| */ | |
| $jin.property.hash({ '$jin.time1.format': { pull: function( pattern ) { | |
| var lexems = $jin.time1.format() | |
| var patterns = Object.keys( lexems ) | |
| patterns.sort() | |
| patterns.reverse() | |
| var funcs = [] | |
| var lexer = RegExp( '(.*?)(' + patterns.join( '|' ) + '|$)', 'g' ) | |
| pattern.replace( lexer, function( str, text, token ){ | |
| if( text ) funcs.push( function(){ return text } ) | |
| if( token ) funcs.push( lexems[ token ] ) | |
| }) | |
| return $jin.concater( funcs ) | |
| }}}) | |