2023-03-30 04:32:17 +00:00
|
|
|
-- Copyright (c) 2023 Willothy
|
|
|
|
-- MIT license, see LICENSE for more details.
|
|
|
|
local lualine_require = require('lualine_require')
|
|
|
|
local M = lualine_require.require('lualine.component'):extend()
|
|
|
|
|
|
|
|
local default_options = {
|
2023-03-30 04:32:45 +00:00
|
|
|
-- default, us, uk, iso, or format (ex. "%d/%m/%Y ...")
|
|
|
|
style = 'default',
|
2023-03-30 04:32:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function M:init(options)
|
2023-03-30 04:32:45 +00:00
|
|
|
M.super.init(self, options)
|
|
|
|
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options)
|
2023-03-30 04:32:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function M:update_status()
|
2023-03-30 04:32:45 +00:00
|
|
|
local fmt = self.options.style
|
|
|
|
if self.options.style == 'default' then
|
|
|
|
fmt = '%A, %B %d | %H:%M'
|
|
|
|
elseif self.options.style == 'us' then
|
|
|
|
fmt = '%m/%d/%Y'
|
|
|
|
elseif self.options.style == 'uk' then
|
|
|
|
fmt = '%d/%m/%Y'
|
|
|
|
elseif self.options.style == 'iso' then
|
|
|
|
fmt = '%Y-%m-%d'
|
|
|
|
end
|
2023-03-30 04:32:17 +00:00
|
|
|
|
2023-03-30 04:32:45 +00:00
|
|
|
return os.date(fmt)
|
2023-03-30 04:32:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|