Skip to content

Commit 0587855

Browse files
author
Sparks, Collin
committed
Replace DateTime with DateTimeOffset
DateTime.UtcNow is now DateTimeOffset.Now.UtcDateTime
1 parent 030fa6f commit 0587855

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

src/Microsoft.ML.Core/Data/DateTime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public DvDateTime Date
7474
/// <summary>
7575
/// Gets a DvDateTime object representing the current UTC date and time.
7676
/// </summary>
77-
public static DvDateTime UtcNow { get { return new DvDateTime(SysDateTime.UtcNow); } }
77+
public static DvDateTime UtcNow { get { return new DvDateTime(SysDateTimeOffset.Now.UtcDateTime); } }
7878

7979
public bool IsNA
8080
{

src/Microsoft.ML.Core/Data/ProgressReporter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ public CalculationInfo(int index, string name, ProgressChannel channel)
359359
Index = index;
360360
Name = name;
361361
PendingCheckpoints = new ConcurrentQueue<KeyValuePair<DateTime, ProgressEntry>>();
362-
StartTime = DateTime.UtcNow;
362+
StartTime = DateTimeOffset.Now.UtcDateTime;
363363
Channel = channel;
364364
}
365365
}
@@ -584,7 +584,7 @@ public ProgressEvent(int index, string name, DateTime startTime, ProgressEntry e
584584
Index = index;
585585
Name = name;
586586
StartTime = startTime;
587-
EventTime = DateTime.UtcNow;
587+
EventTime = DateTimeOffset.Now.UtcDateTime;
588588
Kind = EventKind.Progress;
589589
ProgressEntry = entry;
590590
}
@@ -597,7 +597,7 @@ public ProgressEvent(int index, string name, DateTime startTime, EventKind kind)
597597
Index = index;
598598
Name = name;
599599
StartTime = startTime;
600-
EventTime = DateTime.UtcNow;
600+
EventTime = DateTimeOffset.Now.UtcDateTime;
601601
Kind = kind;
602602
ProgressEntry = null;
603603
}

src/Microsoft.ML.Data/Utilities/TimerScope.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void Dispose()
4646

4747
// REVIEW: This is \n\n is to prevent changes across bunch of baseline files.
4848
// Ideally we should change our comparison method to ignore empty lines.
49-
_ch.Info("{0}\t Time elapsed(s): {1}\n\n", DateTime.UtcNow, elapsedSeconds);
49+
_ch.Info("{0}\t Time elapsed(s): {1}\n\n", DateTimeOffset.Now.UtcDateTime, elapsedSeconds);
5050

5151
using (var pipe = _host.StartPipe<TelemetryMessage>("TelemetryPipe"))
5252
{

src/Microsoft.ML.FastTree/Training/EnsembleCompression/LassoBasedEnsembleCompressor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public unsafe void SetTreeScores(int idx, double[] scores)
164164

165165
private LassoFit GetLassoFit(IChannel ch, int maxAllowedFeaturesPerModel)
166166
{
167-
DateTime startTime = DateTime.UtcNow;
167+
DateTime startTime = DateTimeOffset.Now.UtcDateTime;
168168

169169
if (maxAllowedFeaturesPerModel < 0)
170170
{
@@ -450,7 +450,7 @@ private LassoFit GetLassoFit(IChannel ch, int maxAllowedFeaturesPerModel)
450450
// First lambda was infinity; fixing it
451451
fit.Lambdas[0] = Math.Exp(2 * Math.Log(fit.Lambdas[1]) - Math.Log(fit.Lambdas[2]));
452452

453-
TimeSpan duration = DateTime.UtcNow - startTime;
453+
TimeSpan duration = DateTimeOffset.Now.UtcDateTime - startTime;
454454
ch.Info("Elapsed time for compression: {0}", duration);
455455

456456
return fit;

src/Microsoft.ML.FastTree/TreeEnsemble/Ensemble.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public string ToTreeEnsembleIni(FeaturesToContentMap fmap,
193193

194194
protected int AppendComments(StringBuilder sb, string trainingParams)
195195
{
196-
sb.AppendFormat("\n\n[Comments]\nC:0=Regression Tree Ensemble\nC:1=Generated using FastTree\nC:2=Created on {0}\n", DateTime.UtcNow);
196+
sb.AppendFormat("\n\n[Comments]\nC:0=Regression Tree Ensemble\nC:1=Generated using FastTree\nC:2=Created on {0}\n", DateTimeOffset.Now.UtcDateTime);
197197

198198
string[] trainingParamsList = trainingParams.Split(new char[] { '\n' });
199199
int i = 0;

src/Microsoft.ML.InternalStreams/UnbufferedStream.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,11 +873,11 @@ private bool FillBufferPass()
873873
{
874874
// read into buffer:
875875
int readBytes;
876-
//long t = DateTime.UtcNow.Ticks;
876+
//long t = DateTimeOffset.Now.UtcDateTime.Ticks;
877877
//long startPos = IOUtil.Win32.Raw.GetFilePos(handle);
878878
bool readres = IOUtil.Win32.Raw.ReadFile(_handle, _alignedBuffer[_bufferFillIndex],
879879
(int)Math.Min(_blockSize, _alignedLimit - _totalRead), out readBytes);
880-
//t = DateTime.UtcNow.Ticks - t;
880+
//t = DateTimeOffset.Now.UtcDateTime.Ticks - t;
881881
//Console.WriteLine("core time: " + (t / (double)TimeSpan.TicksPerSecond).ToString("0.000"));
882882
if (!readres)
883883
{

src/Microsoft.ML.Maml/MAML.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ internal static int MainCore(TlcEnvironment env, string args, bool alwaysPrintSt
145145
Path.GetTempPath(),
146146
"TLC");
147147
var dumpFilePath = Path.Combine(dumpFileDir,
148-
string.Format(CultureInfo.InvariantCulture, "Error_{0:yyyyMMdd_HHmmss}_{1}.log", DateTime.UtcNow, Guid.NewGuid()));
148+
string.Format(CultureInfo.InvariantCulture, "Error_{0:yyyyMMdd_HHmmss}_{1}.log", DateTimeOffset.Now.UtcDateTime, Guid.NewGuid()));
149149
bool isDumpSaved = false;
150150
try
151151
{

src/Microsoft.ML.ResultProcessor/ResultProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ private static bool ValidateMamlOutput(string filename, string[] rawLines, out L
584584
Results = runResults,
585585
PerFoldResults = foldResults,
586586
Time = 0,
587-
ExecutionDate = DateTime.UtcNow.ToString()
587+
ExecutionDate = DateTimeOffset.Now.UtcDateTime.ToString()
588588
};
589589
}
590590

src/Microsoft.ML.StandardLearners/Standard/Online/OnlineLinear.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ protected virtual void InitCore(IChannel ch, int numFeatures, LinearPredictor pr
206206
Contracts.Assert(Iteration == 0);
207207
Contracts.Assert(Bias == 0);
208208

209-
ch.Trace("{0} Initializing {1} on {2} features", DateTime.UtcNow, Name, numFeatures);
209+
ch.Trace("{0} Initializing {1} on {2} features", DateTimeOffset.Now.UtcDateTime, Name, numFeatures);
210210
NumFeatures = numFeatures;
211211

212212
// We want a dense vector, to prevent memory creation during training
@@ -253,13 +253,13 @@ protected virtual void BeginIteration(IChannel ch)
253253
Iteration++;
254254
NumIterExamples = 0;
255255

256-
ch.Trace("{0} Starting training iteration {1}", DateTime.UtcNow, Iteration);
256+
ch.Trace("{0} Starting training iteration {1}", DateTimeOffset.Now.UtcDateTime, Iteration);
257257
// #if OLD_TRACING // REVIEW: How should this be ported?
258258
if (Iteration % 20 == 0)
259259
{
260260
Console.Write('.');
261261
if (Iteration % 1000 == 0)
262-
Console.WriteLine(" {0} \t{1}", Iteration, DateTime.UtcNow);
262+
Console.WriteLine(" {0} \t{1}", Iteration, DateTimeOffset.Now.UtcDateTime);
263263
}
264264
// #endif
265265
}
@@ -269,7 +269,7 @@ protected virtual void FinishIteration(IChannel ch)
269269
Contracts.Check(NumIterExamples > 0, NoTrainingInstancesMessage);
270270

271271
ch.Trace("{0} Finished training iteration {1}; iterated over {2} examples.",
272-
DateTime.UtcNow, Iteration, NumIterExamples);
272+
DateTimeOffset.Now.UtcDateTime, Iteration, NumIterExamples);
273273

274274
ScaleWeights();
275275
#if OLD_TRACING // REVIEW: How should this be ported?
@@ -378,7 +378,7 @@ protected virtual void ProcessDataInstance(IChannel ch, ref VBuffer<Float> feat,
378378
if (_numIterExamples % 5000000 == 0)
379379
{
380380
Host.StdOut.Write(" ");
381-
Host.StdOut.Write(DateTime.UtcNow);
381+
Host.StdOut.Write(DateTimeOffset.Now.UtcDateTime);
382382
}
383383
Host.StdOut.WriteLine();
384384
}

0 commit comments

Comments
 (0)