You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TLDR: Date object in front matter incorrectly stringified during conversion process
Describe the bug
When converting Obsidian notes to another platform using the O2 plugin, the date format in the front matter is unexpectedly changed. The plugin is adding time, timezone, and day of the week information to the date, which was not present in the original front matter.
To Reproduce
Steps to reproduce the behavior:
Create a note in Obsidian with a front matter containing a date field (e.g., date: 2021-01-01)
Use the O2 plugin to convert this note
Check the converted note's front matter
Expected behavior
A clear and concise description of what you expected to happen.
The date in the front matter should remain in the same format as the original, e.g., date: 2021-01-01.
Actual behavior
The date in the front matter is converted to a full date-time string with timezone information, e.g., date: Fri Jan 01 2021 09:00:00 GMT+0900 (Korean Standard Time).
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
OS: [e.g. MacOS]
Obsidian version [e.g 1.14.1]
O2 Plugin version [e.g. 1.2.x]
Additional context
Additional context
This issue seems to be caused by the implicit conversion of Date objects to strings in the FrontMatterConverter's join function. The conversion is adding unnecessary detail to the date, which may cause issues when the converted notes are used on other platforms.
// in FrontMatterConverter.ts join()constjoin=(result: FrontMatter,body: string)=>`---${Object.entries(result).map(([key,value])=>`${key}: ${value}`).join('\n')}---${body}`;
The root cause of this issue lies in how JavaScript handles Date objects and string conversions:
Implicit conversion: When converting objects to strings in JavaScript (e.g., using template literals like ${value}), the object's toString() method is called.
Date object's toString(): The toString() method of Date objects returns a full date and time string reflecting the local time zone.
Time zone difference: '2021-01-01T00:00:00.000Z' is in UTC. For Korea (UTC+9), this becomes '2021-01-01 09:00:00' when converted to local time.
Detailed information: toString() includes day of week, full date, time, and time zone information.
The text was updated successfully, but these errors were encountered:
TLDR: Date object in front matter incorrectly stringified during conversion process
Describe the bug
When converting Obsidian notes to another platform using the O2 plugin, the date format in the front matter is unexpectedly changed. The plugin is adding time, timezone, and day of the week information to the date, which was not present in the original front matter.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
The date in the front matter should remain in the same format as the original, e.g.,
date: 2021-01-01
.Actual behavior
The date in the front matter is converted to a full date-time string with timezone information, e.g.,
date: Fri Jan 01 2021 09:00:00 GMT+0900 (Korean Standard Time)
.Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Additional context
This issue seems to be caused by the implicit conversion of Date objects to strings in the FrontMatterConverter's join function. The conversion is adding unnecessary detail to the date, which may cause issues when the converted notes are used on other platforms.
The root cause of this issue lies in how JavaScript handles Date objects and string conversions:
Implicit conversion: When converting objects to strings in JavaScript (e.g., using template literals like
${value}
), the object'stoString()
method is called.Date object's toString(): The
toString()
method of Date objects returns a full date and time string reflecting the local time zone.Time zone difference: '2021-01-01T00:00:00.000Z' is in UTC. For Korea (UTC+9), this becomes '2021-01-01 09:00:00' when converted to local time.
Detailed information:
toString()
includes day of week, full date, time, and time zone information.The text was updated successfully, but these errors were encountered: