-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b42f3a
commit dfc1f5f
Showing
6 changed files
with
38 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/Libraries/CoreNodeModels/Properties/Resources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 23 additions & 4 deletions
27
src/Libraries/CoreNodeModelsWpf/Converters/StringToDateTimeOffsetConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,42 @@ | ||
using System; | ||
using System; | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
using Dynamo.Configuration; | ||
|
||
namespace CoreNodeModelsWpf.Converters | ||
{ | ||
/// <summary> | ||
/// DateTime converter used for Date Time node value conversion | ||
/// </summary> | ||
public class StringToDateTimeConverter : IValueConverter | ||
{ | ||
/// <summary> | ||
/// Convert Date Time object to string using DefaultDateFormat | ||
/// </summary> | ||
/// <param name="value"></param> | ||
/// <param name="targetType"></param> | ||
/// <param name="parameter"></param> | ||
/// <param name="culture"></param> | ||
/// <returns></returns> | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
return ((DateTime)value).ToString(PreferenceSettings.DefaultDateFormat, CultureInfo.InvariantCulture); | ||
} | ||
|
||
/// <summary> | ||
/// Convert input string to Date Time value, try to apply DefaultDateFormat. | ||
/// If conversion fails, use default time. | ||
/// </summary> | ||
/// <param name="value"></param> | ||
/// <param name="targetType"></param> | ||
/// <param name="parameter"></param> | ||
/// <param name="culture"></param> | ||
/// <returns></returns> | ||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
DateTime dt; | ||
return DateTime.TryParseExact(value.ToString(), PreferenceSettings.DefaultDateFormat, | ||
CultureInfo.InvariantCulture, DateTimeStyles.None, out dt) ? | ||
dt : PreferenceSettings.DynamoDefaultTime; | ||
CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dt) ? | ||
dt : PreferenceSettings.DynamoDefaultTime; | ||
} | ||
} | ||
} |