Auto update date when markdown modified not follow `isModifiedDate` date pattern on GitHub Codespaces
dimaslanjaka opened this issue · comments
Describe the bug
Auto update modified date not follow configuration isModifiedDate
To Reproduce
Steps to reproduce the behavior:
- Setup
frontmatter.json
{
"$schema": "https://frontmatter.codes/frontmatter.schema.json",
"frontMatter.content.autoUpdateDate": true,
"frontMatter.preview.host": "http://localhost:4000",
"frontMatter.taxonomy.contentTypes": [
{
"name": "default",
"pageBundle": false,
"fields": [
{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Description",
"name": "description",
"type": "string"
},
{
"title": "Publishing date",
"name": "date",
"type": "datetime",
"default": "{{now}}",
"isPublishDate": true,
"dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX"
},
{
"title": "Thumbnail",
"name": "thumbnail",
"type": "image"
},
{
"title": "Is in draft",
"name": "draft",
"type": "boolean"
},
{
"title": "Tags",
"name": "tags",
"type": "tags"
},
{
"title": "Categories",
"name": "categories",
"type": "categories"
},
{
"title": "updated",
"name": "updated",
"type": "datetime",
"default": "{{now}}",
"isModifiedDate": true,
"dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX"
},
{
"name": "permalink",
"editable": true,
"type": "slug"
},
{
"title": "Author",
"name": "author",
"type": "divider"
}
]
}
],
"frontMatter.framework.id": "hexo",
"frontMatter.content.publicFolder": "hexo:post_asset_folder",
"frontMatter.content.pageFolders": [
{
"path": "[[workspace]]/posts",
"title": "Source Posts"
}
],
"frontMatter.site.baseURL": "https://www.webmanajemen.com/"
}
- Open markdown frontmatter file format
- Edit any text then save
Expected behavior
The modified date should follow format this config
{
"title": "updated",
"name": "updated",
"type": "datetime",
"default": "{{now}}",
"isModifiedDate": true,
"dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX"
}
looks like 2024-06-01T17:14:14+07:00
- hexo date format issue
Screenshots
look at updated: 2024-06-02T00:02:57Z
, it totally wrong and hexo
will produce invalid date format.
Desktop (please complete the following information):
- OS: Ubuntu (Codespace), Windows 10 (PC)
- Browser: Firefox latest
- Version: idk
That is weird, as the date formatting uses the dateFormat
setting in the code. Which version of FM are you using? I cannot reproduce it with your configuration in the stable or beta versions.
Screen.Recording.2024-06-06.at.11.28.53.mov
That is weird, as the date formatting uses the
dateFormat
setting in the code. Which version of FM are you using? I cannot reproduce it with your configuration in the stable or beta versions.
version latest stable. here my screen record - https://drive.google.com/file/d/1n5mbJC9ihCSM1jSxaGMGUdyn3I0FASxY/view?usp=sharing
@estruyf here my full project https://github.com/dimaslanjaka/source-posts/tree/master (branch master and dont forget git submodule update -i -r
)
You can check which parts cause bugs.
Interesting. I cannot reproduce it locally; it is only in a codespace. Will have to find a way how I can test it 🙃
🤦♂️ - there is nothing wrong; it is just that the Codespaces clock is set to UTC. That is why the XXX
results in Z
.
So the yyyy-MM-dd'T'HH:mm:ssXXX
format on a Codespace is formatted to: 2024-06-07T08:02:21Z
.
You can also see this in the date-fns
its format
method documentation: https://date-fns.org/v3.6.0/docs/format - XXX
results in: -08:00, +05:30, Z
Also checked with extra logging in the output:
Here you can see that the dateFormat
value is used for formatting your date.
🤦♂️ - there is nothing wrong; it is just that the Codespaces clock is set to UTC. That is why the
XXX
results inZ
.So the
yyyy-MM-dd'T'HH:mm:ssXXX
format on a Codespace is formatted to:2024-06-07T08:02:21Z
.You can also see this in the
date-fns
itsformat
method documentation: https://date-fns.org/v3.6.0/docs/format -XXX
results in: -08:00, +05:30, ZAlso checked with extra logging in the output:
Here you can see that the
dateFormat
value is used for formatting your date.
when I tap Update NOW working (auto update post date disabled state)
only the auto update modified post wrong format
When you click on the now
button, your browser triggers it, invoking it from the client side, which results in a correct value on your end.
When the automated date update gets invoked, it is on the "backend", which runs on the codespace itself. Because the codespace runs on UTC, it returns a different value.
@dimaslanjaka I found a solution and it is to set the timezone for your GH Codespace. I just wrote a blog post about it on how you can set the timezone for your codespace: https://www.eliostruyf.com/set-timezone-github-codespaces/
@dimaslanjaka I found a solution and it is to set the timezone for your GH Codespace. I just wrote a blog post about it on how you can set the timezone for your codespace: https://www.eliostruyf.com/set-timezone-github-codespaces/
nice working.
here my step to get working (might useful for someone else):
- set timezone in
.devcontainer/devcontainer.json
=> https://github.com/dimaslanjaka/source-posts/blob/d67d837dfc29f57b5f2e43cc9d264486a98c605e/.devcontainer/devcontainer.json#L1-L5 - add timezone change script in dotfiles repository
# timezone.sh
#!/bin/bash
# Set timezone to Asia/Jakarta
sudo ln -sf /usr/share/zoneinfo/Asia/Jakarta /etc/localtime
sudo timedatectl set-timezone Asia/Jakarta
echo "Timezone set to $(date)"
- include the timezone script in
.bashrc
or.zshrc
# your other .bashrc or .zshrc configs
# set timezone
if [ -f ~/dotfiles/timezone.sh ]; then
chmod +x ~/dotfiles/timezone.sh
~/dotfiles/timezone.sh
elif [ -f ./timezone.sh ]; then
chmod +x ./timezone.sh
./timezone.sh
fi
- now rebuild your codespaces
- after finish, open terminal execute command
date