diff m-toolbox/classes/@time/matfrmt2javafrmt.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@time/matfrmt2javafrmt.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,29 @@
+function frmt = matfrmt2javafrmt(frmt)
+% convert MATLAB time formatting specification string into a Java one
+
+  % translate numeric MATLAB time formats into string ones
+  if isnumeric(frmt)
+    frmt = time.getdateform(frmt);
+  end
+  
+  for kk = 1:length(frmt)
+    switch frmt(kk)
+      case 'm'
+        frmt(kk) = 'M';
+      case 'M'
+        frmt(kk) = 'm';
+      case 'S'
+        frmt(kk) = 's';
+      case 'F'
+        frmt(kk) = 'S';
+      case 'P'
+        if frmt(kk+1) == 'M'
+          frmt(kk)   = 'a';
+          frmt(kk+1) = 'a';
+        end
+    end
+  end
+
+  % properly quote the T into ISO8896 date formats
+  frmt = strrep(frmt, 'T', '''T''');
+end