From eb269e137f8a494a670bd4f2ee3370fdfb81e113 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 13 Jul 2016 13:54:45 +0600 Subject: CLOUD: Add BoxListDirectoryByIdRequest Similarly to Google Drive, Box uses only ids of files. That means id resolving would be slow. --- backends/cloud/iso8601.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'backends/cloud/iso8601.cpp') diff --git a/backends/cloud/iso8601.cpp b/backends/cloud/iso8601.cpp index 3bc169ae85..1675c7ce54 100644 --- a/backends/cloud/iso8601.cpp +++ b/backends/cloud/iso8601.cpp @@ -33,6 +33,12 @@ Common::String getSubstring(const Common::String &s, uint32 beginning, uint32 en return result; } +int find(const char *cstr, uint32 startPosition, char needle) { + const char *res = strchr(cstr + startPosition, needle); + if (res == nullptr) return -1; + return res - cstr; +} + } namespace Cloud { @@ -41,12 +47,13 @@ namespace ISO8601 { uint32 convertToTimestamp(const Common::String &iso8601Date) { //2015-05-12T15:50:38Z const char *cstr = iso8601Date.c_str(); - uint32 firstHyphen = strchr(cstr, '-') - cstr; - uint32 secondHyphen = strchr(cstr + firstHyphen + 1, '-') - cstr; - uint32 tSeparator = strchr(cstr + secondHyphen + 1, 'T') - cstr; - uint32 firstColon = strchr(cstr + tSeparator + 1, ':') - cstr; - uint32 secondColon = strchr(cstr + firstColon + 1, ':') - cstr; - uint32 zSeparator = strchr(cstr + secondColon + 1, 'Z') - cstr; + int firstHyphen = find(cstr, 0, '-'); + int secondHyphen = find(cstr, firstHyphen + 1, '-'); + int tSeparator = find(cstr, secondHyphen + 1, 'T'); + int firstColon = find(cstr, tSeparator + 1, ':'); + int secondColon = find(cstr, firstColon + 1, ':'); + int zSeparator = find(cstr, secondColon + 1, 'Z'); + if (zSeparator == -1) zSeparator = find(cstr, secondColon + 1, '-'); // Box's RFC 3339 //now note '+1' which means if there ever was '-1' result of find(), we still did a valid find() from 0th char Common::String year = getSubstring(iso8601Date, 0, firstHyphen); -- cgit v1.2.3