| 1 |
-- Copyright (c) 2023 Willothy |
| 2 |
-- MIT license, see LICENSE for more details. |
| 3 |
local lualine_require = require('lualine_require') |
| 4 |
local M = lualine_require.require('lualine.component'):extend() |
| 5 |
|
| 6 |
local default_options = { |
| 7 |
-- default, us, uk, iso, or format (ex. "%d/%m/%Y ...") |
| 8 |
style = 'default', |
| 9 |
} |
| 10 |
|
| 11 |
function M:init(options) |
| 12 |
M.super.init(self, options) |
| 13 |
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options) |
| 14 |
end |
| 15 |
|
| 16 |
function M:update_status() |
| 17 |
local fmt = self.options.style |
| 18 |
if self.options.style == 'default' then |
| 19 |
fmt = '%A, %B %d | %H:%M' |
| 20 |
elseif self.options.style == 'us' then |
| 21 |
fmt = '%m/%d/%Y' |
| 22 |
elseif self.options.style == 'uk' then |
| 23 |
fmt = '%d/%m/%Y' |
| 24 |
elseif self.options.style == 'iso' then |
| 25 |
fmt = '%Y-%m-%d' |
| 26 |
end |
| 27 |
|
| 28 |
return os.date(fmt) |
| 29 |
end |
| 30 |
|
| 31 |
return M |