Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcos Henrich <marcos.henrich@xamarin.com>2014-10-06 18:32:45 +0400
committerMarcos Henrich <marcos.henrich@xamarin.com>2014-10-06 18:32:45 +0400
commit27d26c36cc3f4f8c9558de81854a5020ec94bd62 (patch)
tree6dfc1468e58a35ff51ae4c171ddb1bd469c19c1b /mcs/class/corlib/DateTime.Now_Test.sh
parent2a73a83d8919141e16a19ce22ecf9805117b7cba (diff)
Added bash script to test DateTime.Now.
The test changes TZ environment variable and compares DateTime.Now with system date. The test checks all the timezones installed in /usr/share/zoneinfo/.
Diffstat (limited to 'mcs/class/corlib/DateTime.Now_Test.sh')
-rwxr-xr-xmcs/class/corlib/DateTime.Now_Test.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/mcs/class/corlib/DateTime.Now_Test.sh b/mcs/class/corlib/DateTime.Now_Test.sh
new file mode 100755
index 00000000000..27b9c2014d2
--- /dev/null
+++ b/mcs/class/corlib/DateTime.Now_Test.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+export MONO_PATH=${MONO_PATH:-$SCRIPT_PATH/../lib/net_4_5/}
+
+TZ_FAILS=0
+TZ_COUNT=0
+FORMAT="%a %b %d %T %Y"
+
+for tz in $(cd /usr/share/zoneinfo/; find * -type f -print); do
+ TZ_COUNT=$(expr $TZ_COUNT + 1)
+ SYS_DATETIME=$(date -ju -f "$FORMAT" "$(TZ=$tz date "+$FORMAT")" "+%s")
+ CS_DATETIME=$(TZ=$tz csharp -e '(int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds;')
+ DIFF=$(expr $SYS_DATETIME - $CS_DATETIME)
+ if [ "$DIFF" -gt "5" ] || [ "$DIFF" -lt "-5" ]; then
+ TZ_FAILS=$(expr $TZ_FAILS + 1)
+ echo ""
+ echo "DateTime.Now failed with timezone: $tz"
+ echo " System: $(date -ju -f "%s" "$SYS_DATETIME" "+%Y-%m-%d %T")"
+ echo " DateTime.Now: $(date -ju -f "%s" "$CS_DATETIME" "+%Y-%m-%d %T")"
+ fi
+ echo ".\c"
+done
+echo ""
+echo "DateTime.Now failed with $TZ_FAILS of $TZ_COUNT timezones."