vanBassum / Wakatime.Unity

A Wakatime plugin for Unity
MIT License
36 stars 7 forks source link

Heartbeat collector doesn't specify culture when calling Float.ToString #18

Closed lgarczyn closed 7 months ago

lgarczyn commented 7 months ago

In this snippet:

        private Heartbeat CreateHeartbeat(string entity)
        {
            string workingDir = Path.GetDirectoryName(entity);
            Heartbeat heartbeat = new Heartbeat
            {
                Entity = entity,
                EntityType = EntityTypes.File,
                Timestamp = DateTime.Now.ToUnixTimeFloat().ToString(),
                Project = Settings.ProjectName,
                BranchName = GitClient?.GetBranchName(workingDir),
                IsWrite = false,
                Category = Application.isPlaying ? HeartbeatCategories.Debugging : HeartbeatCategories.Coding,
            };
            return heartbeat;
        }

DateTime.Now.ToUnixTimeFloat().ToString() should be Timestamp = DateTime.Now.ToUnixTimeFloat().ToString(CultureInfo.InvariantCulture),

Otherwise if the current culture uses comma as a number seperator, you get errors such as:

Error: invalid argument "1,702235E+09" for "--time" flag: strconv.ParseFloat: parsing "1,702235E+09": invalid syntax

vanBassum commented 7 months ago

Thanks for the effort, I have merged your pull request.