RasmusBroborg / DotnetTimecode

Dotnet Timecode is a C# class library for working with SMPTE Timecodes defined by the Society of Motion Picture and Television Engineers in the SMPTE 12M specification.
MIT License
8 stars 6 forks source link

Add static methods for operations without having to initialize objects. #20

Closed RasmusBroborg closed 2 years ago

RasmusBroborg commented 2 years ago

All methods in the Timecode.cs class should also be available as static methods.

Example use case:

// Arrange
using DotnetTimecode;
using DotnetTimecode.Enums;

var originalTimecode = "10:00:00:00";
var originalFramerate = Framerate.fps24;
var destinationFramerate = Framerate.fps25;

// Act
var convertedTimecode = Timecode.ConvertFramerate(originalTimecode, originalFramerate, destinationFramerate); // Static method call

// Assert
convertedTimecode == "09:36:00:00"; // Should be true
GopinathRakkiyannan commented 2 years ago

@RasmusBroborg I would like to work on this issue. Could you please assign on my name.

I have clarification as well, Do we need to change all the methods to static or you would need all the methods as another copy with static?

RasmusBroborg commented 2 years ago

Hi @GopinathRakkiyannan, I will assign you to the issue.

It is good that you ask for clarification. The static methods should mirror the instance methods (ie copy as you say). The intent for this is to enable more flexible workflows for the end users.

Please let me know if this answer is sufficient, or if you would like me provide examples.

GopinathRakkiyannan commented 2 years ago

@RasmusBroborg

Could you please update some examples here. That would help me lot. Thanks in advance

RasmusBroborg commented 2 years ago

@GopinathRakkiyannan Please see below for more examples:

Example 1:

using DotnetTimecode;
using DotnetTimecode.Enums;

// Static method call
string inputString = "10:00:00:00";
int numberOfHoursToAdd = 2;
string result = Timecode.AddHours(inputString, numberOfHoursToAdd); // result will be the string value "12:00:00:00"

// Instance method call
Timecode timecode = new Timecode("10:00:00:00", Framerate.fps24);
timecode.AddHours(2);
string result = timecode.ToString(); // result will be the string value "12:00:00:00"

Example 2:

using DotnetTimecode;
using DotnetTimecode.Enums;

// Static method call
string inputString = "10:00:00:00";
int numberOfMinutesToAdd = -2;
string result = Timecode.AddMinutes(inputString, numberOfMinutesToAdd ); // result will be the string value "09:58:00:00"

// Instance method call
Timecode timecode = new Timecode("10:00:00:00", Framerate.fps24);
timecode.AddMinutes(-2);
string result = timecode.ToString(); // result will be the string value "09:58:00:00"

Example 3:

using DotnetTimecode;
using DotnetTimecode.Enums;

// Static method call
string inputString = "10:00:00:00";
int numberOfFramesToAdd = 25;
Framerate framerate = Framerate.fps24
string result = Timecode.AddFrames(inputString, numberOfFramesToAdd, framerate); // result will be the string value "10:00:01:01"

// Instance method call
Timecode timecode = new Timecode("10:00:00:00", Framerate.fps24);
timecode.AddFrames(25);
string result = timecode.ToString(); // result will be the string value "10:00:01:01"
GopinathRakkiyannan commented 2 years ago

@RasmusBroborg Thanks for the info. This will help me more!. I will let you know once I done with the implementation as soon

RasmusBroborg commented 2 years ago

@GopinathRakkiyannan Happy coding!

hiteshbhavsar commented 2 years ago

Hello, @RasmusBroborg is there anywhere I can help in this issue?

RasmusBroborg commented 2 years ago

Fixed in #35