-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add timezone conversion. #37
Merged
laura-ding
merged 9 commits into
vesoft-inc:master
from
Shylock-Hg:feature/timezone-conversion
Jul 1, 2021
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fe9d7ee
Add timezone conversion.
Shylock-Hg f88fbf8
Merge branch 'master' into feature/timezone-conversion
Shylock-Hg 481d76e
Merge branch 'master' into feature/timezone-conversion
Shylock-Hg 7a384c3
Add the test of time zone coversion.
Shylock-Hg 16ac88c
Merge branch 'feature/timezone-conversion' of github.com:Shylock-Hg/n…
Shylock-Hg aedfd6d
Merge branch 'master' into feature/timezone-conversion
Shylock-Hg 234e786
Using the time conversion method.
Shylock-Hg e1c530d
Merge branch 'feature/timezone-conversion' of github.com:Shylock-Hg/n…
Shylock-Hg 040d1f3
Fix the compile error for auto return type.
Shylock-Hg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* Copyright (c) 2021 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#include <atomic> | ||
#include <chrono> | ||
#include <thread> | ||
|
||
#include <folly/synchronization/Baton.h> | ||
#include <glog/logging.h> | ||
#include <gtest/gtest.h> | ||
#include <gtest/gtest_prod.h> | ||
|
||
#include <nebula/client/ConnectionPool.h> | ||
#include <nebula/client/Init.h> | ||
#include <nebula/client/Session.h> | ||
|
||
#include "./ClientTest.h" | ||
|
||
// Require a nebula server could access | ||
|
||
#define kServerHost "graphd" | ||
|
||
class SessionTest : public ClientTest {}; | ||
|
||
TEST_F(SessionTest, Basic) { | ||
nebula::ConnectionPool pool; | ||
pool.init({kServerHost ":9669"}, nebula::Config{}); | ||
auto session = pool.getSession("root", "nebula"); | ||
ASSERT_TRUE(session.valid()); | ||
{ | ||
auto resp = session.execute("YIELD datetime(\"2019-03-22T22:04:30\") as dt," | ||
"date(\"2019-03-22\") as d, " | ||
"time(\"22:04:30\") as t"); | ||
nebula::DataSet data({"dt", "d", "t"}); | ||
data.emplace_back(nebula::Row({nebula::DateTime(2019, 3, 22, 22, 4, 30, 0), | ||
nebula::Date(2019, 3, 22), | ||
nebula::Time(22, 4, 30, 0)})); | ||
EXPECT_TRUE(verifyResultWithoutOrder(resp, data)); | ||
|
||
// conversion | ||
session.toLocal(*resp.data); | ||
EXPECT_TRUE(verifyResultWithoutOrder(*resp.data, data)); | ||
} | ||
{ | ||
auto resp = session.execute("YIELD datetime(\"2019-03-22T22:04:30\") as dt," | ||
"date(\"2019-03-22\") as d, " | ||
"time(\"22:04:30\") as t"); | ||
nebula::DataSet data({"dt", "d", "t"}); | ||
data.emplace_back(nebula::Row({nebula::DateTime(2019, 3, 22, 22, 4, 30, 0), | ||
nebula::Date(2019, 3, 22), | ||
nebula::Time(22, 4, 30, 0)})); | ||
EXPECT_TRUE(verifyResultWithoutOrder(resp, data)); | ||
|
||
// conversion | ||
session.toLocal(*resp.data, 30); | ||
nebula::DataSet expectLocal({"dt", "d", "t"}); | ||
expectLocal.emplace_back(nebula::Row({nebula::DateTime(2019, 3, 22, 22, 5, 0, 0), | ||
nebula::Date(2019, 3, 22), | ||
nebula::Time(22, 5, 0, 0)})); | ||
EXPECT_TRUE(verifyResultWithoutOrder(*resp.data, expectLocal)); | ||
} | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
testing::InitGoogleTest(&argc, argv); | ||
nebula::init(&argc, &argv); | ||
google::SetStderrLogging(google::INFO); | ||
|
||
return RUN_ALL_TESTS(); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to provide a method like that, but you can tell user how to get localTime and get localDateTime in example code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interface better move to test code, no need to provide it to the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User could use or not.