- 
                Notifications
    
You must be signed in to change notification settings  - Fork 398
 
Open
Labels
bugSomething isn't workingSomething isn't working
Description
🔎 是否已搜索类似问题?
是,未找到相同问题
🚨 问题详情与复现方式
问题现象
srt字幕文件中,时间码的毫秒部分计算错误,例如,73.23应该转换为00:01:13,230,但实际转换为00:01:13,023
关键代码
/// <summary>
/// 秒数转 时:分:秒 格式
/// </summary>
/// <param name="seconds"></param>
/// <returns></returns>
private static string Second2hms(float seconds)
{
    if (seconds < 0)
    {
        return "00:00:00,000";
    }
    int i = (int)Math.Floor(seconds / 1.0);
    int dec = (int)(Math.Round(seconds % 1.0f, 2) * 100);
    if (dec >= 100)
    {
        dec = 99;
    }
    int min = (int)Math.Floor(i / 60.0);
    int second = (int)(i % 60.0f);
    int hour = (int)Math.Floor(min / 60.0);
    min = (int)Math.Floor(min % 60.0f);
    return $"{hour:D2}:{min:D2}:{second:D2},{dec:D3}";
}建议修改
int dec = (int)(Math.Round(seconds % 1.0f, 3) * 1000);
if (dec >= 1000)
{
    dec = 999;
}或者以字符串解析
📂 环境信息(必填)
- downkyiCore 版本:
1.0.23 - 操作系统:
Windows 10 
⚠️  已尝试的解决方案
- 更新至最新版本
 - 检查网络连接(尝试切换网络环境):cite[2]:cite[6]
 - 更改解析模式(API/网页解析):cite[4]
 - 更换下载器(Aria2/内建下载器)
 
📎 补充信息
错误格式
正确格式
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working

