mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	Fixes issue #441: Dates were not parsed on sorting
This commit is contained in:
		
							parent
							
								
									9220616bb5
								
							
						
					
					
						commit
						270aa52591
					
				@ -68,8 +68,16 @@ class OrderByAndLimitExp extends Expression {
 | 
				
			|||||||
                    return larger;
 | 
					                    return larger;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                // if both are dates, then parse them for dates comparison
 | 
				
			||||||
 | 
					                if (typeof valA === "string" && this.isDate(valA) &&
 | 
				
			||||||
 | 
					                    typeof valB === "string" && this.isDate(valB)) {
 | 
				
			||||||
 | 
					                    valA = new Date(valA);
 | 
				
			||||||
 | 
					                    valB = new Date(valB);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // if both are numbers, then parse them for numerical comparison
 | 
					                // if both are numbers, then parse them for numerical comparison
 | 
				
			||||||
                if (typeof valA === "string" && this.isNumber(valA) &&
 | 
					                else if (typeof valA === "string" && this.isNumber(valA) &&
 | 
				
			||||||
                    typeof valB === "string" && this.isNumber(valB)) {
 | 
					                    typeof valB === "string" && this.isNumber(valB)) {
 | 
				
			||||||
                    valA = parseFloat(valA);
 | 
					                    valA = parseFloat(valA);
 | 
				
			||||||
                    valB = parseFloat(valB);
 | 
					                    valB = parseFloat(valB);
 | 
				
			||||||
@ -99,6 +107,10 @@ class OrderByAndLimitExp extends Expression {
 | 
				
			|||||||
        return noteSet;
 | 
					        return noteSet;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    isDate(date: number | string) {
 | 
				
			||||||
 | 
					      return (new Date(date) !== "Invalid Date") && !isNaN(new Date(date));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    isNumber(x: number | string) {
 | 
					    isNumber(x: number | string) {
 | 
				
			||||||
        if (typeof x === 'number') {
 | 
					        if (typeof x === 'number') {
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user