コンテンツにスキップ

現在、全3219曲を聴きながらリンク集を作成中のサグラダ・ファミリア サイトです。
情報の誤りやお問い合わせは、管理人 X までお寄せください。
✨ オススメのプレイリストやセトリを教えて下さい ✨

Module:MemberStats

今日も推しが尊いですね。― ハロプロ・サブスク非公式リンク集
2026年2月20日 (金) 10:41時点におけるBarageki (トーク | 投稿記録)による版 (ページの作成:「local p = {} function p.averageAge(frame) local args = frame.args local totalAge = 0 local count = 0 -- 今日の日付を取得 (YYYYMMDD) local today = tonumber(os.date("%Y%m%d")) -- 引数から生年月日をスキャン for _, birthStr in ipairs(args) do local birth = tonumber(birthStr) if birth then -- 年齢計算ロジック: floor((今日 - 誕生日) / 10000) local age = math.fl…」)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)

local p = {}

function p.averageAge(frame)

   local args = frame.args
   local totalAge = 0
   local count = 0
   
   -- 今日の日付を取得 (YYYYMMDD)
   local today = tonumber(os.date("%Y%m%d"))
   
   -- 引数から生年月日をスキャン
   for _, birthStr in ipairs(args) do
       local birth = tonumber(birthStr)
       if birth then
           -- 年齢計算ロジック: floor((今日 - 誕生日) / 10000)
           local age = math.floor((today - birth) / 10000)
           totalAge = totalAge + age
           count = count + 1
       end
   end
   
   if count == 0 then return "0" end
   
   -- 平均を出して小数第2位で丸める
   local avg = totalAge / count
   return string.format("%.2f", avg)

end

function p.count(frame)

   local count = 0
   for _, _ in ipairs(frame.args) do
       count = count + 1
   end
   return count

end

return p