diff --git a/Codist/AutoBuildVersion/VersionRewriteMode.cs b/Codist/AutoBuildVersion/VersionRewriteMode.cs
index 091c9861..0a962cb5 100644
--- a/Codist/AutoBuildVersion/VersionRewriteMode.cs
+++ b/Codist/AutoBuildVersion/VersionRewriteMode.cs
@@ -14,6 +14,7 @@ public enum VersionRewriteMode
DayOfYear,
Hour,
HourMinute,
- DaySinceY2K
+ DaySinceY2K,
+ MidNightSecond
}
}
diff --git a/Codist/AutoBuildVersion/VersionSetting.cs b/Codist/AutoBuildVersion/VersionSetting.cs
index 366758f1..0b1563f7 100644
--- a/Codist/AutoBuildVersion/VersionSetting.cs
+++ b/Codist/AutoBuildVersion/VersionSetting.cs
@@ -5,6 +5,8 @@ namespace Codist.AutoBuildVersion
{
public sealed class VersionSetting
{
+ const int MaxVersionNumber = 65535;
+
static readonly IFormatProvider __Format = System.Globalization.CultureInfo.InvariantCulture;
public VersionRewriteMode Major { get; set; }
public VersionRewriteMode Minor { get; set; }
@@ -27,7 +29,7 @@ public string Rewrite(string major, string minor, string build, string revision)
string WritePart(string part, VersionRewriteMode mode) {
switch (mode) {
- case VersionRewriteMode.Increment: return Int32.TryParse(part, System.Globalization.NumberStyles.Integer, __Format, out var n) ? (++n).ToText() : part;
+ case VersionRewriteMode.Increment: return Int32.TryParse(part, System.Globalization.NumberStyles.Integer, __Format, out var n) ? NormalizeNumber(++n) : part;
case VersionRewriteMode.Zero: return "0";
case VersionRewriteMode.Year: return DateTime.Now.Year.ToText();
case VersionRewriteMode.Month: return DateTime.Now.Month.ToText();
@@ -38,7 +40,8 @@ string WritePart(string part, VersionRewriteMode mode) {
case VersionRewriteMode.DayOfYear: return DateTime.Now.DayOfYear.ToText();
case VersionRewriteMode.Hour: return DateTime.Now.Hour.ToText();
case VersionRewriteMode.HourMinute: return DateTime.Now.Hour.ToText() + DateTime.Now.Minute.ToString("00", __Format);
- case VersionRewriteMode.DaySinceY2K: return ((int)(DateTime.Now.Date - new DateTime(2000, 1, 1)).TotalDays).ToText();
+ case VersionRewriteMode.DaySinceY2K: return NormalizeNumber((int)(DateTime.Now.Date - new DateTime(2000, 1, 1)).TotalDays);
+ case VersionRewriteMode.MidNightSecond: return ((int)((DateTime.Now - DateTime.Today).TotalSeconds / 2)).ToText();
default: return part;
}
}
@@ -46,5 +49,9 @@ string WritePart(string part, VersionRewriteMode mode) {
public override string ToString() {
return $"{Major}.{Minor}.{Build}.{Revision}";
}
+
+ static string NormalizeNumber(int n) {
+ return (n > MaxVersionNumber ? MaxVersionNumber : n < 0 ? 0 : n).ToText();
+ }
}
}
diff --git a/Codist/Properties/Resources.Designer.cs b/Codist/Properties/Resources.Designer.cs
index edfaa39b..41916ace 100644
--- a/Codist/Properties/Resources.Designer.cs
+++ b/Codist/Properties/Resources.Designer.cs
@@ -5477,7 +5477,7 @@ internal static string T_VersionNumberNotFound {
}
///
- /// 查找类似 Unchanged/Increment/Zero/Year/Month/Date/ShortYear/YearMonth/MonthDate/DayOfYear/Hour/HourMinute/DaySinceY2K 的本地化字符串。
+ /// 查找类似 Unchanged/Increment/Zero/Year/Month/Date/ShortYear/YearMonth/MonthDate/DayOfYear/Hour/HourMinute/DaySinceY2K/MidNightSecond 的本地化字符串。
///
internal static string T_VersionRewriteMode {
get {
diff --git a/Codist/Properties/Resources.en-US.resx b/Codist/Properties/Resources.en-US.resx
index 182428cb..cc3cb19d 100644
--- a/Codist/Properties/Resources.en-US.resx
+++ b/Codist/Properties/Resources.en-US.resx
@@ -1850,7 +1850,7 @@ Right click: Wrap text menu...
Configuration:
- Unchanged/Increment/Zero/Year/Month/Date/ShortYear/YearMonth/MonthDate/DayOfYear/Hour/HourMinute/DaySinceY2K
+ Unchanged/Increment/Zero/Year/Month/Date/ShortYear/YearMonth/MonthDate/DayOfYear/Hour/HourMinute/DaySinceY2K/MidNightSecond
Save
diff --git a/Codist/Properties/Resources.resx b/Codist/Properties/Resources.resx
index b85b9885..ac3cf9c4 100644
--- a/Codist/Properties/Resources.resx
+++ b/Codist/Properties/Resources.resx
@@ -1854,7 +1854,7 @@ ALL existing items will be REPLACE by default items.
Configuration:
- Unchanged/Increment/Zero/Year/Month/Date/ShortYear/YearMonth/MonthDate/DayOfYear/Hour/HourMinute/DaySinceY2K
+ Unchanged/Increment/Zero/Year/Month/Date/ShortYear/YearMonth/MonthDate/DayOfYear/Hour/HourMinute/DaySinceY2K/MidNightSecond
Save
diff --git a/Codist/Properties/Resources.zh-Hans.resx b/Codist/Properties/Resources.zh-Hans.resx
index 4331904b..d32af47c 100644
--- a/Codist/Properties/Resources.zh-Hans.resx
+++ b/Codist/Properties/Resources.zh-Hans.resx
@@ -1839,7 +1839,7 @@ Ctrl+1, Ctrl+3: Edit.SearchDeclarationInProject
生成项目的配置:
- 不变/加1/置0/年yyyy/月m/日d/年yy/年月yymm/月日mdd/年日ddd/时h/时分hmm/2000年起日
+ 不变/加1/置0/年yyyy/月m/日d/年yy/年月yymm/月日mdd/年日ddd/时h/时分hmm/2000年起日/午夜起双秒
保存