cannot run rust PrimitiveDateTime example - date

I'm trying to solve a very simple rust exercise involving PrimitiveDateTime. I'm trying to run this basic example in my own machine
#![allow(unused)]
extern crate r#time;
fn main() {
use time::{
macros::{date, datetime, time},
PrimitiveDateTime,
};
assert_eq!(
PrimitiveDateTime::new(date!(2019 - 01 - 01), time!(0:00)),
datetime!(2019-01-01 0:00),
);
}
It compile on the rust playground, but it gives me the following errors on my machine:
$ cargo run
Compiling playground v0.1.0 (/home/sas/exercism/rust/playground)
error[E0432]: unresolved imports `time::macros`, `time::PrimitiveDateTime`, `time::macros::date`, `time::macros::datetime`
--> src/main.rs:4:12
|
4 | use time::{PrimitiveDateTime, macros::{date, datetime, time}};
| ^^^^^^^^^^^^^^^^^ ^^^^^^ ^^^^ ^^^^^^^^
| |
| could not find `macros` in `time`
error: cannot find macro `date` in this scope
--> src/main.rs:6:28
|
6 | PrimitiveDateTime::new(date!(2019-01-01), time!(0:00)),
| ^^^^
error: cannot determine resolution for the macro `time`
--> src/main.rs:6:47
|
6 | PrimitiveDateTime::new(date!(2019-01-01), time!(0:00)),
| ^^^^
|
= note: import resolution is stuck, try simplifying macro imports
error: cannot find macro `datetime` in this scope
--> src/main.rs:7:5
|
7 | datetime!(2019-01-01 0:00),
| ^^^^^^^^
error[E0433]: failed to resolve: use of undeclared type `PrimitiveDateTime`
--> src/main.rs:6:5
|
6 | PrimitiveDateTime::new(date!(2019-01-01), time!(0:00)),
| ^^^^^^^^^^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
3 | use time::PrimitiveDateTime;
|
error[E0659]: `time` is ambiguous (name vs any other name during import resolution)
--> src/main.rs:4:5
|
4 | use time::{PrimitiveDateTime, macros::{date, datetime, time}};
| ^^^^ ambiguous name
|
note: `time` could refer to the unresolved item imported here
--> src/main.rs:4:56
|
4 | use time::{PrimitiveDateTime, macros::{date, datetime, time}};
| ^^^^
note: `time` could also refer to the crate imported here
--> src/main.rs:2:1
|
2 | extern crate r#time;
| ^^^^^^^^^^^^^^^^^^^^
= help: use `::time` to refer to this crate unambiguously
= help: or use `crate::time` to refer to this crate unambiguously
Some errors have detailed explanations: E0432, E0433, E0659.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `playground` due to 6 previous errors
This is my Cargo.toml file:
[package]
name = "playground"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
time = "0.3.5"
I'd like to know how to solve it and to understand the error it throws. It seems like some conflict between the time crate and the macro.

Quite a few things in the time crate are feature flag gated, meaning you need to manually specify some feature to enable a certain feature. In your case the macros are missing, taking a look at time's crates.io page shows us you need to add the feature macros to enable this. You can do this by specifying your dependency like so:
[dependencies]
time = { version = "0.3.5", features = ["macros"] }

Related

Stata, string variable to quartely time series

I have a data set with this type of observations:
"2015_1"
"2015_2"
"2015_3"
I want to convert to time series(quarterly), like:
2015q1
2015q2
2015q3
This is a standard conversion task. See help datetime and help datetime display formats for the detail.
* Example generated by -dataex-. To install: ssc install dataex
clear
input str6 have
"2015_1"
"2015_2"
"2015_3"
end
gen wanted = quarterly(have, "YQ")
format wanted %tq
list
+-----------------+
| have wanted |
|-----------------|
1. | 2015_1 2015q1 |
2. | 2015_2 2015q2 |
3. | 2015_3 2015q3 |
+-----------------+
describe
Contains data
obs: 3
vars: 2
---------------------------------------------------------------------------------------------
storage display value
variable name type format label variable label
---------------------------------------------------------------------------------------------
have str6 %6s
wanted float %tq
-------------------------------------------------------------------------------------

Highchart org chart type error with ionic application

Implementing Highcharts organisation chart with ionic application using https://www.highcharts.com/docs/chart-and-series-types/organization-chart resulted in the following error
ERROR in src/app/home/home.page.ts:29:11 - error TS2322: Type 'string' is not assignable to type '"area" | "map" | "line" | "polygon" | "item" | "abands" | "ad" | "ao" | "apo" | "arearange" | "areaspline" | "areasplinerange" | "aroon" | "aroonoscillator" | "atr" | "bar" | "bb" | ... 80 more ... | "zigzag"'.
[ng] 29 type: 'organization',
[ng] ~~~~
[ng] node_modules/highcharts/highcharts.d.ts:189657:5
[ng] 189657 type: "abands";
[ng] ~~~~
[ng] The expected type comes from property 'type' which is declared here on type 'SeriesAbandsOptions | SeriesAdOptions | SeriesAoOptions | SeriesApoOptions | SeriesAreaOptions | SeriesArearangeOptions | SeriesAreasplineOptions | SeriesAreasplinerangeOptions | ... 89 more ... | SeriesZigzagOptions'
[ng]
I included the required scripts in index.html file.
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/sankey.js"></script>
<script src="https://code.highcharts.com/modules/organization.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
import * as HighCharts from 'highcharts';
import highcharts from "highcharts/modules/organization";
highcharts(HighCharts);
How do I fix the issue ?
Try to import it like that:
import * as Highcharts from "highcharts";
import * as Sankey from "highcharts/modules/sankey";
import * as Organization from "highcharts/modules/organization";
import * as HighchartsExporting from "highcharts/modules/exporting";
Sankey(Highcharts);
Organization(Highcharts);
HighchartsExporting(Highcharts);
Angular Demo:
https://codesandbox.io/s/angular-qdq4f

How to use a macro which is defined by another macro in the same crate?

I'm defining a macro that defines other macros like this:
macros.rs
#[macro_export]
macro_rules! m1 {
() => {
#[macro_export]
macro_rules! m2 {
() => {}
}
}
}
m1!();
m2!(); // no problem;
I can use m2! in another crate by use {{crate_name}}::macros::*, and I can use m2! in macros.rs, but I don't know how to use m2! in files that are in the same crate.
lib.rs
#[macro_use]
pub mod macros;
pub mod test;
pub mod test2;
test.rs (in the same crate as macros.rs)
use crate::m1; // no problem
use crate::m2; // ERROR: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
m1!(); // no problem
m2!(); // error, no m2
test2.rs
use crate::*;
m2!(); // this works, but I don't really want to use crate::*
examples/yo.rs
use {{crate_name}}::m2;
m2!(); // no problem
What is the correct way to use that m2 macro in other files in the same crate? I'm using Rust 1.31.1.
Read and follow the compiler's instructions:
error[E0659]: `m2` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
--> src/lib.rs:22:5
|
22 | m2!();
| ^^ ambiguous name
|
note: `m2` could refer to the macro defined here
--> src/lib.rs:7:13
|
7 | / macro_rules! m2 {
8 | | () => {};
9 | | }
| |_____________^
...
21 | m1!();
| ------ in this macro invocation
note: `m2` could also refer to the macro defined here
--> src/lib.rs:7:13
|
7 | / macro_rules! m2 {
8 | | () => {};
9 | | }
| |_____________^
...
13 | m1!();
| ------ in this macro invocation
error: a macro named `m2` has already been exported
--> src/lib.rs:7:13
|
7 | / macro_rules! m2 {
8 | | () => {};
9 | | }
| |_____________^ `m2` already exported
...
21 | m1!();
| ------ in this macro invocation
|
= note: #[deny(duplicate_macro_exports)] on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
= note: for more information, see issue #35896 <https://github.com/rust-lang/rust/issues/35896>
note: previous macro export is now shadowed
--> src/lib.rs:7:13
|
7 | / macro_rules! m2 {
8 | | () => {};
9 | | }
| |_____________^
...
13 | m1!();
| ------ in this macro invocation
error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
--> src/lib.rs:19:9
|
19 | use crate::m2;
| ^^^^^^^^^
|
= note: #[deny(macro_expanded_macro_exports_accessed_by_absolute_paths)] on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #52234 <https://github.com/rust-lang/rust/issues/52234>
note: the macro is defined here
--> src/lib.rs:7:13
|
7 | / macro_rules! m2 {
8 | | () => {};
9 | | }
| |_____________^
...
21 | m1!();
| ------ in this macro invocation
Specifically:
error: macro-expanded macro_export macros from the current crate cannot be referred to by absolute paths
Applied:
Don't import the macro; there's no need.
Don't call m1; doing so creates a second m2.
test.rs
// use crate::m1;
// use crate::m2;
// m1!();
m2!();

An example from multiple source files in Doxygen

I am documenting a group of classes that work together using Doxygen and I wrote an example spread across multiple source files (All referenced from EXAMPLE_PATH). More precisely, I wrote the following:
/*************************************//**
* Some context...
* #example Source1.cpp
*
* More context...
* #example Source2.cpp
****************************************/
The problem is that the output is spread in half in the Example page generated by Doxygen (a page for Source1, another for Source2). I would like it to be all on the same HTML page, with the context and example code together as one tutorial:
Some context...
|----------------------------------------------|
| int main() |
| { |
| //... |
| } |
|----------------------------------------------|
More context...
|----------------------------------------------|
| bool fct() |
| { |
| //... |
| } |
|----------------------------------------------|
Is there a way to accomplish this? I am using Doxygen 1.8.11.
Regards
I found a semi-legit solution: if you add the #example tag at the beginning and use #includes afterwards, it works:
/*************************************//**
* #example "My tutorial"
*
* Some context...
* #include Source1.cpp
*
* More context...
* #include Source2.cpp
****************************************/
However, looking at the error output from Doxygen I get the following message: warning: included file My is not found. Check your EXAMPLE_PATH
The solution is not clean, but is usable for the time being. If you have a better suggestion (i.e. warning removed), please share it and I will accept it.

Where can I find the documentation for MicroStrategy Command Manager

Where can I find the documentation for MicroStrategy Command Manager? I've look through various docs that I have but not able to find any comprehensive list of commands. Particularly, I need to know a list of commands to create attributes and metrics.
Thanks
The best way to find the list of available commands is to use the Outlines option, available inside Command Manager.
To create an attribute use the following syntax:
CREATE ATTRIBUTE "<attribute_name>" [DESCRIPTION "<description>"] [LONGDESCRIPTION "<long_description>"] IN [FOLDER] "<location_path>" [HIDDEN (TRUE | FALSE)] ATTRIBUTEFORM "<form_name>" [FORMCATEGORY "<category_name>"] [FORMDESC "<form_description>"] [FORMTYPE (NUMBER | TEXT | DATETIME | DATE | TIME | URL | EMAIL | HTML | PICTURE | BIGDECIMAL | PHONENUMBER)] [REPORTSORT (NONE | ASC | DESC)] [BROWSESORT (NONE | ASC | DESC)] EXPRESSION "<form_expression>" [MAPPINGMODE (AUTOMATIC | MANUAL)] [EXPSOURCETABLES "<sourcetable1>" [, "<sourcetable2>" ...]] LOOKUPTABLE "<lookup_table>" FOR PROJECT "<project_name>";
and for metrics creation:
CREATE METRIC "<metric_name>" IN [FOLDER] "<location_path>" EXPRESSION "<expression>" [DESCRIPTION "<description>"] [LONGDESCRIPTION "<long_description>"] [HIDDEN (TRUE | FALSE)] [ALLOWSMARTMETRIC (TRUE | FALSE)] [REMOVEREPORTFILTERELEMENTS (TRUE | FALSE)] [TOTALSUBTOTALFUNCTION (AVERAGE | COUNT | DEFAULT| GEOMETRICMEAN | MAXIMUM | MEDIAN | MINIMUM | MODE | NONE | PRODUCT | STANDARDDEVIATION | SUM | VARIANCE)] [DYNAMICAGGREGATIONFUNCTION (AVERAGE | COUNT | DEFAULT| GEOMETRICMEAN | MAXIMUM | MEDIAN | MINIMUM | MODE | NONE | PRODUCT | STANDARDDEVIATION | SUM | VARIANCE)] [COLUMNALIAS "<columnalias>"] FOR PROJECT "<project_name>";
Some simple examples provided bellow (again from the outlines available inside command manager):
CREATE ATTRIBUTE "Day" DESCRIPTION "Duplicate of Day Attribute from folder \Time" IN FOLDER "\Schema Objects\Attributes" ATTRIBUTEFORM "ID" FORMCATEGORY "ID" FORMDESC "Basic ID form" FORMTYPE TEXT REPORTSORT ASC EXPRESSION "[DAY_DATE]" LOOKUPTABLE "LU_DAY" FOR PROJECT "MicroStrategy Tutorial";
CREATE METRIC "New Metric" IN FOLDER "\Public Objects\Metrics\Count Metrics" EXPRESSION "Count(Customer) {Country} <[Western United States Customers]>" FOR PROJECT "MicroStrategy Tutorial";
As Bruno said, the Outlines option gives you all the templates that there are in Command Manager, which you can build together and define to do what you want. If in doubt, check out the "MicroStrategy System Administration Guide" product manual, which covers all you need to know on command manager.
Here is one useful site with Command Manager documentation:
https://metacpan.org/pod/Business::Intelligence::MicroStrategy::CommandManager