Comments (4)
this is my temporary solution:
import "github.com/shopspring/decimal"
// formatDuration formats a duration
func formatDuration(i time.Duration, millisecondSep string, numberOfMillisecondDigits int) (s string) {
// Parse hours
var hours = int(i / time.Hour)
var n = i % time.Hour
if hours < 10 {
s += "0"
}
s += strconv.Itoa(hours) + ":"
// Parse minutes
var minutes = int(n / time.Minute)
n = i % time.Minute
if minutes < 10 {
s += "0"
}
s += strconv.Itoa(minutes) + ":"
// Parse seconds
var seconds = int(n / time.Second)
n = i % time.Second
if seconds < 10 {
s += "0"
}
s += strconv.Itoa(seconds) + millisecondSep
// Parse milliseconds
var milliseconds = float64(n/time.Millisecond) / float64(1000)
// PCT 解决精度丢失问题
decimalMs := decimal.NewFromFloat(milliseconds)
round := decimalMs.RoundFloor(int32(numberOfMillisecondDigits)).InexactFloat64()
s += fmt.Sprintf("%."+strconv.Itoa(numberOfMillisecondDigits)+"f", round)[2:]
// s += fmt.Sprintf("%."+strconv.Itoa(numberOfMillisecondDigits)+"f", milliseconds)[2:]
return
}
from go-astisub.
I've pushed a fix on master based on your provided test data, could you confirm your problem is now resolved?
Let me know whether you need a tag 👍
from go-astisub.
I've pushed a fix on master based on your provided test data, could you confirm your problem is now resolved?
Let me know whether you need a tag 👍
There's nothing wrong with my test,tks
from go-astisub.
Closing this issue then 👍
from go-astisub.
Related Issues (20)
- clean up go.sum
- Access for adding new features to base HOT 1
- DVD Studio Pro reader and writer
- iTunes Timed Text reader and writer
- not support .ass file? HOT 4
- Populate originalEpisodeTitle and originalProgramTitle for STL file convertion HOT 4
- Can go-astisub parse HDMV/PGS subtitle? HOT 1
- convert ass subtitle contains more than one language to vtt fail HOT 6
- Can't change fontColor for STL file HOT 2
- TTML text parsing issues with new lines HOT 1
- What to expect to be supported by ttml parser? HOT 5
- Support AddItem(s) and RemoveItem(s) HOT 2
- Handle dot as well for SRT files HOT 1
- Subtitles.go String() - why are subtitle lines joined with a " - ", instead of a new line ("\n")? HOT 3
- Escape problem when convert from other formats to VTT, and from VTT to other formats HOT 11
- Example usage ReadFromSRT in the README is incorrect HOT 4
- Broken VTT styling in output (0.26.0 only) HOT 3
- The indexes always are zero (v0.26.1 only) HOT 2
- Timestamp tag regression in 0.26.0 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-astisub.