本文整理汇总了C#中Time类的典型用法代码示例。如果您正苦于以下问题:C# Time类的具体用法?C# Time怎么用?C# Time使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Time类属于命名空间,在下文中一共展示了Time类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Time Now = new Time(12, 34, 56);
Console.WriteLine((int)Now);
Console.WriteLine((double)Now);
Console.WriteLine(Now);
}
示例2: can_extract_time_from_datetime
public void can_extract_time_from_datetime()
{
var compareTime = new Time(13, 59);
var dateTime = new DateTime(2011, 3, 5, 13, 59, 0);
var time = dateTime.TimeOfTheDay();
Assert.AreEqual(time, compareTime);
}
示例3: can_parse_time_two_digit_hours
public void can_parse_time_two_digit_hours()
{
var compareTime = new Time(13, 59);
string timeValue = "13:59:00";
var time = timeValue.ToTimeOfDay();
Assert.AreEqual(time, compareTime);
}
示例4: AnimatedSprite
public AnimatedSprite(Time frameTime, bool paused, bool looped)
{
FrameTime = frameTime;
Pause = paused;
Loop = looped;
_vertices = new Vertex[4];
}
示例5: Update
public void Update(Time deltaTime)
{
if (Pause || Animation == null) return;
// add delta time
_currentTime += deltaTime;
// if current time is bigger than frame time, advance one frame
if (_currentTime <= FrameTime) return;
// reset time, but keep remainder
_currentTime = _currentTime % FrameTime;
// get next frame index
if (_currentFrame + 1 < Animation.Frames.Count)
{
_currentFrame++;
}
else
{
// animation has ended
_currentFrame = 0;
if (!Loop)
{
Pause = true;
}
}
SetFrame(_currentFrame, false);
}
示例6: Main
static void Main()
{
Time Now = new Time(12, 34, 56);
Now.OutTime();
Now["분"] = 19;
Console.WriteLine("분은 {0}입니다.", Now["분"]);
}
示例7: Can_Add_Minutes
public void Can_Add_Minutes()
{
Time time = new Time(22, 30);
time = time.AddMinutes(105);
Assert.AreEqual(0, time.Hour);
Assert.AreEqual(15, time.Minute);
}
示例8: can_format_24hour_time
public void can_format_24hour_time()
{
var compareTime = new Time(13, 59, 58, "HH:mm:ss");
var time = compareTime.ToString();
string timeValue = "13:59:58";
Assert.AreEqual(time, timeValue);
}
示例9: Constructor
/** == Time units
* Whenever durations need to be specified, eg for a timeout parameter, the duration can be specified
* as a whole number representing time in milliseconds, or as a time value like `2d` for 2 days.
*
* === Using Time units in NEST
* NEST uses `Time` to strongly type this and there are several ways to construct one.
*
* ==== Constructor
* The most straight forward way to construct a `Time` is through its constructor
*/
[U] public void Constructor()
{
var unitString = new Time("2d");
var unitComposed = new Time(2, Nest.TimeUnit.Day);
var unitTimeSpan = new Time(TimeSpan.FromDays(2));
var unitMilliseconds = new Time(1000 * 60 * 60 * 24 * 2);
/**
* When serializing Time constructed from
* - a string
* - milliseconds (as a double)
* - composition of factor and interval
* - a `TimeSpan`
*
* the expression will be serialized to a time unit string composed of the factor and interval e.g. `2d`
*/
Expect("2d")
.WhenSerializing(unitString)
.WhenSerializing(unitComposed)
.WhenSerializing(unitTimeSpan)
.WhenSerializing(unitMilliseconds);
/**
* The `Milliseconds` property on `Time` is calculated even when not using the constructor that takes a double
*/
unitMilliseconds.Milliseconds.Should().Be(1000*60*60*24*2);
unitComposed.Milliseconds.Should().Be(1000*60*60*24*2);
unitTimeSpan.Milliseconds.Should().Be(1000*60*60*24*2);
unitString.Milliseconds.Should().Be(1000*60*60*24*2);
}
示例10: VerifyAllEnums
public void VerifyAllEnums()
{
var acceleration = new Acceleration(1, AccelerationUnit.BaseUnit);
var angle = new Angle(1, AngleUnit.BaseUnit);
var angularAcceleration = new AngularAcceleration(1, AngularAccelerationUnit.BaseUnit);
var area = new Area(1, AreaUnit.BaseUnit);
var density = new MassDensity(1, MassDensityUnit.BaseUnit);
var electricCurrent = new ElectricCurrent(1, ElectricCurrentUnit.BaseUnit);
var electricResistance = new ElectricResistance(1, ElectricResistanceUnit.BaseUnit);
var electricVoltage = new ElectricPotential(1, ElectricPotentialUnit.BaseUnit);
var energy = new Energy(1, EnergyUnit.BaseUnit);
var force = new Force(1, ForceUnit.BaseUnit);
var frequency = new Frequency(1, FrequencyUnit.BaseUnit);
var jerk = new Jerk(1, JerkUnit.BaseUnit);
var length = new Length(1, LengthUnit.BaseUnit);
var mass = new Mass(1, MassUnit.BaseUnit);
var massFlowRate = new MassFlowRate(1, MassFlowRateUnit.BaseUnit);
var momentum = new Momentum(1, MomentumUnit.BaseUnit);
var numeric = new Numeric(1, NumericUnit.BaseUnit);
var power = new Power(1, PowerUnit.BaseUnit);
var pressure = new Pressure(1, PressureUnit.BaseUnit);
var speed = new Speed(1, SpeedUnit.BaseUnit);
var temperature = new Temperature(1, TemperatureUnit.BaseUnit);
var time = new Time(1, TimeUnit.BaseUnit);
var torque = new Torque(1, TorqueUnit.BaseUnit);
var volume = new Volume(1, VolumeUnit.BaseUnit);
var volumetricFlowRate = new VolumetricFlowRate(1, VolumetricFlowRateUnit.BaseUnit);
}
示例11: can_format_12hour_time
public void can_format_12hour_time()
{
var compareTime = new Time(13, 59, 58, "h:mm:ss tt");
var time = compareTime.ToString();
string timeValue = "1:59:58 " + Thread.CurrentThread.CurrentCulture.DateTimeFormat.PMDesignator;
Assert.AreEqual(time, timeValue);
}
示例12: New
public static StrategyDecision New(
Directive processDirective,
MessageDirective messageDirective,
IEnumerable<ProcessId> affects,
Time pause
) =>
new StrategyDecision(processDirective, messageDirective, affects, pause);
示例13: Report
public Report(Time time, IState state)
{
if(null == state)
throw new ArgumentNullException("state");
_time = time;
_state = state;
}
示例14: Call
public Call (DateTime date, Time time, string dialledPhoneNumber, int duration)
{
this.Date = date;
this.Time = time;
this.DialledPhoneNumber = dialledPhoneNumber;
this.Duration = duration;
}
示例15: TimeSlot
public TimeSlot(int number, Time startTime, TimeSpan duration, bool isAvailable)
{
Number = number;
StartTime = startTime;
Duration = duration;
IsAvailable = isAvailable;
}