cacglo
June 19, 2024, 5:25am
1
Dear Aspose Support Team,
We are currently using Aspose.Words for extracting comments from Word documents in our application. One of our requirements is to retrieve the timezone information associated with each comment, if available.
Could you please provide guidance or examples on how to extract comments along with their timezone information
@cacglo You can get Comment.DateTimeUtc .
Document doc = new Document("C:\\Temp\\in.docx");
Comment c = (Comment)doc.getChild(NodeType.COMMENT, 0, true);
System.out.println(c.getDateTime());
System.out.println(c.getDateTimeUtc());
System.out.println(getCurrentTimezoneOffset(c.getDateTimeUtc()));
public static String getCurrentTimezoneOffset(Date d) {
TimeZone tz = TimeZone.getDefault();
int offsetInMillis = tz.getOffset(d.getTime());
String offset = String.format("%02d:%02d", Math.abs(offsetInMillis / 3600000), Math.abs((offsetInMillis / 60000) % 60));
offset = (offsetInMillis >= 0 ? "+" : "-") + offset;
return offset;
}
cacglo
June 19, 2024, 5:40am
3
We are using python for the same can u provide python code snippet
@cacglo Here is Python code:
doc = aw.Document("C:\\Temp\\in.docx")
c = doc.get_child(aw.NodeType.COMMENT, 0, True).as_comment()
print(c.date_time)
print(c.date_time_utc)
print(c.date_time_utc.astimezone().tzinfo.utcoffset(c.date_time_utc))
See the following link for more information:
https://www.geeksforgeeks.org/python-datetime-tzinfo/