A personal nvim plugin for converting between Julian date and epoch timestamp.
Note that this plugin in written for me, for a custom use case, and is not intended for a general purpose. It is public in case it might prove helpful for anyone else struggling with the horrors of Julian date representations.
- Neovim 0.7.0+ required
- Install using your favorite plugin manager
- Example using lazy.nvim
{
"alexpresthus/julian.nvim"
}
If you want to configure default keymaps, run require'julian'.setup()
. Using lazy.nvim:
{
"alexpresthus/julian.nvim",
opts = {}
}
This will configure the keymaps:
vim.keymap.set("n", "<leader>jdf", function()
local julian_date = vim.fn.input("Enter Julian date: ")
return M.julian_to_epoch(julian_date)
end)
vim.keymap.set("n", "<leader>jdt", function()
local epoch_time = vim.fn.input("Enter epoch time: ")
return M.epoch_to_julian(epoch_time)
end)
Converts a Julian date to an epoch timestamp (milliseconds).
require'julian'.julian_to_epoch(2460300)
Julian: 2460300 -> Epoch: 1703160000000
require'julian'.julian_to_epoch(2460368.365544)
Julian: 2460368.365544 -> Epoch: 1709066783002
Converts an epoch timestamp (milliseconds) to a Julian date.
require'julian'.epoch_to_julian(1709066783002)
Epoch: 1709066783002 -> Julian: 2460368.365544