mirror of
				https://github.com/gpxstudio/gpx.studio.git
				synced 2025-11-04 05:21:09 +00:00 
			
		
		
		
	catch invalid dates on export, closes #180
This commit is contained in:
		@@ -96,14 +96,19 @@ export function parseGPX(gpxData: string): GPXFile {
 | 
			
		||||
export function buildGPX(file: GPXFile, exclude: string[]): string {
 | 
			
		||||
    const gpx = file.toGPXFileType(exclude);
 | 
			
		||||
 | 
			
		||||
    let lastDate = undefined;
 | 
			
		||||
    const builder = new XMLBuilder({
 | 
			
		||||
        format: true,
 | 
			
		||||
        ignoreAttributes: false,
 | 
			
		||||
        attributeNamePrefix: '',
 | 
			
		||||
        attributesGroupName: 'attributes',
 | 
			
		||||
        suppressEmptyNode: true,
 | 
			
		||||
        tagValueProcessor: (tagName: string, tagValue: unknown): string => {
 | 
			
		||||
        tagValueProcessor: (tagName: string, tagValue: unknown): string | undefined => {
 | 
			
		||||
            if (tagValue instanceof Date) {
 | 
			
		||||
                if (isNaN(tagValue.getTime())) {
 | 
			
		||||
                    return lastDate?.toISOString();
 | 
			
		||||
                }
 | 
			
		||||
                lastDate = tagValue;
 | 
			
		||||
                return tagValue.toISOString();
 | 
			
		||||
            }
 | 
			
		||||
            return tagValue.toString();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user