Isse 542 - allow integers to be converted to dates
git-svn-id: http://google-refine.googlecode.com/svn/trunk@2450 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
b784046b18
commit
4a99abf25d
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright 2010,2011. Google Inc.
|
Copyright 2010,2012. Google Inc.
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@ -57,15 +57,19 @@ public class ToDate implements Function {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Object arg0 = args[0];
|
Object arg0 = args[0];
|
||||||
|
String o1;
|
||||||
if (arg0 instanceof Date) {
|
if (arg0 instanceof Date) {
|
||||||
return arg0;
|
return arg0;
|
||||||
} else if (arg0 instanceof Calendar) {
|
} else if (arg0 instanceof Calendar) {
|
||||||
return ((Calendar) arg0).getTime();
|
return ((Calendar) arg0).getTime();
|
||||||
} else if (!(arg0 instanceof String)) {
|
} else if (arg0 instanceof Long) {
|
||||||
|
o1 = ((Long) arg0).toString(); // treat integers as years
|
||||||
|
} else if (arg0 instanceof String) {
|
||||||
|
o1 = (String) arg0;
|
||||||
|
} else {
|
||||||
// ignore cell values that aren't strings
|
// ignore cell values that aren't strings
|
||||||
return new EvalError("Not a String - cannot parse to date");
|
return new EvalError("Not a String - cannot parse to date");
|
||||||
}
|
}
|
||||||
String o1 = (String) arg0;
|
|
||||||
|
|
||||||
// "o, boolean month_first (optional)"
|
// "o, boolean month_first (optional)"
|
||||||
if (args.length == 1 || (args.length == 2 && args[1] instanceof Boolean)) {
|
if (args.length == 1 || (args.length == 2 && args[1] instanceof Boolean)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user