10 examples of 'd3 timeparse' in JavaScript

Every line of 'd3 timeparse' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
46function d3_time_parse(date, template, string, j) {
47 var c,
48 p,
49 i = 0,
50 n = template.length,
51 m = string.length;
52 while (i < n) {
53 if (j >= m) return -1;
54 c = template.charCodeAt(i++);
55 if (c == 37) {
56 p = d3_time_parsers[template.charAt(i++)];
57 if (!p || ((j = p(date, string, j)) < 0)) return -1;
58 } else if (c != string.charCodeAt(j++)) {
59 return -1;
60 }
61 }
62 return j;
63}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

235function d3_time_parseYear(date, string, i) {
236 d3_time_numberRe.lastIndex = 0;
237 var n = d3_time_numberRe.exec(string.substring(i, i + 2));
238 return n ? (date.setFullYear(d3_time_century() + +n[0]), i += n[0].length) : -1;
239}
335function d3_time_parseSeconds(date, string, i) {
336 d3_time_numberRe.lastIndex = 0;
337 var n = d3_time_numberRe.exec(string.slice(i, i + 2));
338 return n ? (date.S = +n[0], i + n[0].length) : -1;
339}
105export function parseDate(d: string): Date {
106 const matches = d.match(/\d+/);
107 return new Date(parseInt(matches![0], 10));
108}
288function d3_time_parseYear(date, string, i) {
289 d3_time_numberRe.lastIndex = 0;
290 var n = d3_time_numberRe.exec(string.slice(i, i + 2));
291 return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1;
292}
193function d3_time_parseFullYear(date, string, i) {
194 d3_time_numberRe.lastIndex = 0;
195 var n = d3_time_numberRe.exec(string.substring(i, i + 4));
196 return n ? (date.y = +n[0], i += n[0].length) : -1;
197}
64function toDate (s) {
65 let a = s.split(/[^0-9]/)
66 let dateStr = a[0] + '-' + a[1] + '-' + a[2] + 'T' + a[3] + ':' + a[4] + 'Z'
67
68 return new Date(dateStr)
69}
55function parseDate(str){
56 var matches = /(\d+)[^\d](\d+)[^\d](\d+)/.exec(str);
57 var time;
58 if(matches){
59 time = (new Date(+matches[3], matches[2]-1, +matches[1])).getTime();
60 AnyBalance.trace('Parsing date ' + new Date(time) + ' from value: ' + str);
61 return time;
62 }
63 AnyBalance.trace('Could not parse date from value: ' + str);
64}
46function parseDate(date) {
47 var re = date.match("([0-9]+)-([0-9]+)-([0-9]+) ([0-9]+):([0-9]+):.*");
48 return (re[2] + '/' + re[3] + '/' + re[1] + ' ' + re[4] + ':' + re[5]);
49}
323function d3_time_parseHour24(date, string, i) {
324 d3_time_numberRe.lastIndex = 0;
325 var n = d3_time_numberRe.exec(string.slice(i, i + 2));
326 return n ? (date.H = +n[0], i + n[0].length) : -1;
327}

Related snippets