mirror of
https://github.com/openbullet/openbullet.git
synced 2023-10-21 07:33:42 -05:00
Added support to specify the format string in UnixTimeToDate
(Probably makes UnixTimeToISO8601 deprecated?) inadvertently found and fixed a bug where saving some default values is required.
This commit is contained in:
@@ -237,6 +237,7 @@ FUNCTION Translate StopAfterFirstMatch=True
|
|||||||
KEY "key2" VALUE "value2"
|
KEY "key2" VALUE "value2"
|
||||||
"input" -> CAP "Translated"
|
"input" -> CAP "Translated"
|
||||||
FUNCTION DateToUnixTime "format" "input" -> VAR "DATE"
|
FUNCTION DateToUnixTime "format" "input" -> VAR "DATE"
|
||||||
|
FUNCTION UnixTimeToDate "format" "input" -> VAR "UNIXTIME"
|
||||||
FUNCTION Replace "what" "with" UseRegex=True "input" -> VAR "REPLACED"
|
FUNCTION Replace "what" "with" UseRegex=True "input" -> VAR "REPLACED"
|
||||||
FUNCTION RegexMatch "pattern" "input" -> VAR "MATCHED"
|
FUNCTION RegexMatch "pattern" "input" -> VAR "MATCHED"
|
||||||
FUNCTION RandomNum "0" "100" -> VAR "RANDOM"
|
FUNCTION RandomNum "0" "100" -> VAR "RANDOM"
|
||||||
|
|||||||
@@ -236,6 +236,18 @@
|
|||||||
</DockPanel>
|
</DockPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem x:Name="unixTimeToDateTab">
|
||||||
|
<StackPanel>
|
||||||
|
<DockPanel>
|
||||||
|
<Label Content="Date Format:"/>
|
||||||
|
<TextBox Text="{Binding DateFormat, UpdateSourceTrigger=PropertyChanged}">
|
||||||
|
<TextBox.ToolTip>
|
||||||
|
<TextBlock>Key characters:<LineBreak/>y: year<LineBreak/>M: month<LineBreak/>d: day<LineBreak/>H: hour<LineBreak/>m: minute<LineBreak/>s: second</TextBlock>
|
||||||
|
</TextBox.ToolTip>
|
||||||
|
</TextBox>
|
||||||
|
</DockPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</TabItem>
|
||||||
</TabControl>
|
</TabControl>
|
||||||
|
|
||||||
<TextBlock Grid.Row="2" x:Name="functionInfoTextblock" TextWrapping="WrapWithOverflow" Foreground="{DynamicResource ForegroundMain}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
<TextBlock Grid.Row="2" x:Name="functionInfoTextblock" TextWrapping="WrapWithOverflow" Foreground="{DynamicResource ForegroundMain}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
|||||||
@@ -136,6 +136,10 @@ namespace OpenBullet.Views.StackerBlocks
|
|||||||
case BlockFunction.Function.PBKDF2PKCS5:
|
case BlockFunction.Function.PBKDF2PKCS5:
|
||||||
functionTabControl.SelectedIndex = 15;
|
functionTabControl.SelectedIndex = 15;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case BlockFunction.Function.UnixTimeToDate:
|
||||||
|
functionTabControl.SelectedIndex = 16;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -375,6 +375,16 @@ namespace RuriLib
|
|||||||
DateFormat = LineParser.ParseLiteral(ref input, "DATE FORMAT");
|
DateFormat = LineParser.ParseLiteral(ref input, "DATE FORMAT");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Function.UnixTimeToDate:
|
||||||
|
DateFormat = LineParser.ParseLiteral(ref input, "DATE FORMAT");
|
||||||
|
// a little backward compatability with the old line format.
|
||||||
|
if (LineParser.Lookahead(ref input) != TokenType.Literal)
|
||||||
|
{
|
||||||
|
InputString = DateFormat;
|
||||||
|
DateFormat = "yyyy-MM-dd:HH-mm-ss";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case Function.Replace:
|
case Function.Replace:
|
||||||
ReplaceWhat = LineParser.ParseLiteral(ref input, "What");
|
ReplaceWhat = LineParser.ParseLiteral(ref input, "What");
|
||||||
ReplaceWith = LineParser.ParseLiteral(ref input, "With");
|
ReplaceWith = LineParser.ParseLiteral(ref input, "With");
|
||||||
@@ -525,7 +535,12 @@ namespace RuriLib
|
|||||||
|
|
||||||
case Function.DateToUnixTime:
|
case Function.DateToUnixTime:
|
||||||
writer
|
writer
|
||||||
.Literal(DateFormat, "DateFormat");
|
.Literal(DateFormat, "DateFormat", true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Function.UnixTimeToDate:
|
||||||
|
writer
|
||||||
|
.Literal(DateFormat, "DateFormat", true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Function.Replace:
|
case Function.Replace:
|
||||||
@@ -718,7 +733,7 @@ namespace RuriLib
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Function.UnixTimeToDate:
|
case Function.UnixTimeToDate:
|
||||||
outputString = double.Parse(localInputString).ToDateTime().ToShortDateString();
|
outputString = double.Parse(localInputString).ToDateTime().ToString(dateFormat);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Function.CurrentUnixTime:
|
case Function.CurrentUnixTime:
|
||||||
|
|||||||
@@ -63,10 +63,11 @@ namespace RuriLib.LS
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="literal">The literal value to write</param>
|
/// <param name="literal">The literal value to write</param>
|
||||||
/// <param name="property">The name of the property of the block. If the value is the default one, it will not be written. Do not set this parameter to always write the variable.</param>
|
/// <param name="property">The name of the property of the block. If the value is the default one, it will not be written. Do not set this parameter to always write the variable.</param>
|
||||||
|
/// <param name="alwaysWrite">Always write the value even if that value is default</param>
|
||||||
/// <returns>The BlockWriter itself</returns>
|
/// <returns>The BlockWriter itself</returns>
|
||||||
public BlockWriter Literal(string literal, string property = "")
|
public BlockWriter Literal(string literal, string property = "", bool alwaysWrite = false)
|
||||||
{
|
{
|
||||||
if (property != string.Empty && CheckDefault(literal, property)) return this;
|
if (property != string.Empty && (!alwaysWrite && CheckDefault(literal, property))) return this;
|
||||||
Write($"\"{literal.Replace("\\", "\\\\").Replace("\"", "\\\"")}\" ");
|
Write($"\"{literal.Replace("\\", "\\\\").Replace("\"", "\\\"")}\" ");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user